我想循环而不选择细胞。范围B:B将包含我想要编号的值列表:10
,20
,30
等等。我知道如何实现这一点,但它没有还没工作:
Dim i as integer
i = 1
Do While i < 200
If Range("Bi") <> "" Then
Range("Ai")= i*10
end if
i = i + 1
Loop
End sub
有没有人知道如何做到这样的事情?
这会起作用还是根本没有任何意义?:
Dim i as integer
Dim a as String
Dim b as String
Dim c as integer
i = 1
Do While i < 200
a = "A"& i
b = "B"& i
c = i * 10
If Range(b) <>"" Then
Range(a) = c
End if
i = i + 1
Loop
End Sub
答案 0 :(得分:3)
如果您不想创建范围地址字符串,可以使用单元格将数字索引用于行和列。
Dim i As Integer
Dim c As Long
i = 1
c = 10
Do While i < 200
Cells(i, 2).Value = c
i = i + 1
c = c + 10
Loop
答案 1 :(得分:1)
你的第一个片段几乎就在那里。这有效:
advertisingTrackingEnabled
关键是要使Range选择像这样:Sub SetNumbers()
Dim i As Integer
i = 1
Do While i < 200
If Range("B" & i) <> "" Then
Range("A" & i) = i * 10
End If
i = i + 1
Loop
End Sub
。
答案 2 :(得分:0)
<强> Anwser 强>
我尝试过这似乎有效
Dim i as integer
Dim a as String
Dim b as String
Dim c as integer
i = 1
Do While i < 200
a = "A"& i
b = "B"& i
c = i * 10
If Range(b) <>"" Then
Range(a) = c
End if
i = i + 1
Loop
End Sub