VBA For列上的循环

时间:2016-09-26 17:10:11

标签: excel vba

enter image description here

大家好我试图在列上循环这些值(上图中每行2个值)。

我想要的是传递给for循环值是" A = 1,B = 1"," A = 1,B = 2"等等。

我尝试使用以下代码,但它无效。

Dim cell As Range
Dim celula As Range

Set rng = Worksheets("PARAM").Range("A2:A9")
Set runge = Worksheets("PARAM").Range("B2:B9")

For Each cell In rng
For Each celula In runge

e.Visible = False
ie.navigate "http://www.examples/test" & **cell** & "/" & **celula**

Do While ie.readyState <> READYSTATE_COMPLETE

DoEvents

Loop

1 个答案:

答案 0 :(得分:0)

可能的纠正

Dim i%

For i = 2 To 9 ' will send 9 requests based on the value of column A and column B

e.Visible = False
ie.navigate "http://www.examples/test" & Cells(i, 1) & "/" & Cells(i, 2)

Do While ie.readyState <> READYSTATE_COMPLETE

DoEvents

Loop
Next i