Excel VBA求助

Dim A as string
Dim i as integer
For i = 1 to 5
怎樣可得到
A1 = 1
A2 =2

...

next i

回覆 1# chanman60

留名學野

講笑的方法
A1=1
A2=2
A3=3
A4=4
A5=5

TOP

Dim A as string
Dim i as integer
For i = 1 to 5
怎樣可得到
A1 = 1
A2 =2

...

next i
chanman60 發表於 2019-1-30 20:13



A1, A2呢D都係variable, 唔需要特別為佢設定個名. 一般用array己經做到相同效果

Dim A(100)
For i =1 to 5
A(i)=i
Next i

如果你真係好想係sheet / report show到有你A1相對就係1, A2相對係2既效果, 可以用2d array
Dim A(100,2)
For i =1 to 5
A(i,1)="A"&i
A(i,2)=i
Next i

For i=1 to 5
cells(i,1)=A(i,1)
cells(i,2)=A(i,2)
next i

TOP

謝謝解答

TOP

問题已用array 解决了。謝謝各位。

TOP