VB循环编程怎么弄啊A B C Daa Jack I am is aa,you is bb,cc is pig too...bb Mike you are aa,I am bb,pig is cc too...cc Yao she is aa,you is bb,cc is pig too.......要求把C列中的单元格里用公式将 aa bb cc.替换成 B列中的相对应

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/08 14:23:14
VB循环编程怎么弄啊A B C Daa Jack I am is aa,you is bb,cc is pig too...bb Mike you are aa,I am bb,pig is cc too...cc Yao she is aa,you is bb,cc is pig too.......要求把C列中的单元格里用公式将 aa bb cc.替换成 B列中的相对应
xT]OA+ ٬)4mi*6ho"hRb_Bmc5[aw>ιw枳~Wucit7 Iq9?hIz*)3hI(@$ё, Bp%QQe= Ϩ"JP ,08(JQ><9Y (m7ƅ2,ҪQ1q+ d5): 8,cW6(gV A`TP/F[G `iOސJNE]KZ9VqULL&cVԵnbρ XEFHfJ2> V޲@>9*bf oQrF#)B6{Y2[IQ%)r\\lfk+,:b,܏P0|b_$D2ba7u^GjH;ӷ܃K\ͽlNuY e Ea E]}7e;Tfex0 d.b4Gg[,cY_*~'8qK3E܊rid>LMSj4Mkf ^껤3S幐M8l{㽚eX2:i5v/pbtJ%M&6 P]쬓Hj/}H Y]&w톻QuF[wҜ"p63lb "ô;X

VB循环编程怎么弄啊A B C Daa Jack I am is aa,you is bb,cc is pig too...bb Mike you are aa,I am bb,pig is cc too...cc Yao she is aa,you is bb,cc is pig too.......要求把C列中的单元格里用公式将 aa bb cc.替换成 B列中的相对应
VB循环编程怎么弄啊
A B C D
aa Jack I am is aa,you is bb,cc is pig too...
bb Mike you are aa,I am bb,pig is cc too...
cc Yao she is aa,you is bb,cc is pig too...
....
要求把C列中的单元格里用公式将 aa bb cc.替换成 B列中的相对应的内容,如aa替换成Jack,bb 代换成 Mike.
C列中每一个单元格要多次使用SUBSTITUTE替换.不是只替换一次.
唉.我已经折腾了三天了.没有结果.
要用VB循环编程.

VB循环编程怎么弄啊A B C Daa Jack I am is aa,you is bb,cc is pig too...bb Mike you are aa,I am bb,pig is cc too...cc Yao she is aa,you is bb,cc is pig too.......要求把C列中的单元格里用公式将 aa bb cc.替换成 B列中的相对应
怎么说呢,这里有个很简单的方法,就是用replace函数,你自己可以试下:

Dim a(1 To 3, 1 To 2) As String
Dim c(1 To 3) As String
Dim d(1 To 3) As String
Dim i As Integer
Dim j As Integer
a(1, 1) = "aa": a(1, 2) = "Jack"
a(2, 1) = "bb": a(2, 2) = "Mike"
a(3, 1) = "cc": a(3, 2) = "Yao"

c(1) = "I am is aa, you is bb, cc is pig too..."
c(2) = "you are aa, I am bb, pig is cc too..."
c(3) = "she is aa, you is bb, cc is pig too..."

For i = 1 To UBound(c)
d(i) = c(i)
For j = 1 To 3
d(i) = Replace(d(i), a(j, 1), a(j, 2))
Next
Debug.Print d(i)
Next


在这里我用的数组是固定维数的,如果无法确定数组上限时,就用动态数组吧,你自己再改下就行了

调试结果:
I am is Jack, you is Mike, Yao is pig too...
you are Jack, I am Mike, pig is Yao too...
she is Jack, you is Mike, Yao is pig too...