Vba 创建宏以填写在线表单时,循环设置不正确
这是代码块的中间部分,我添加了一个循环来访问每个单元格并将其值传递给变量 我省略了代码中创建IE对象、访问网站等的部分,因为它似乎工作正常。这个循环是我不确定的 我需要改变什么Vba 创建宏以填写在线表单时,循环设置不正确,vba,Vba,这是代码块的中间部分,我添加了一个循环来访问每个单元格并将其值传递给变量 我省略了代码中创建IE对象、访问网站等的部分,因为它似乎工作正常。这个循环是我不确定的 我需要改变什么 Dim name As String Dim address As String Dim city As String Dim state As String Dim zip As String Dim phone As String Range.Row = i For i = 2 To 626
Dim name As String
Dim address As String
Dim city As String
Dim state As String
Dim zip As String
Dim phone As String
Range.Row = i
For i = 2 To 626
name = Cells(A, i).Value
address = Cells(B, i).Value
city = Cells(C, i).Value
state = Cells(D, i).Value
zip = Cells(E, i).Value
phone = Cells(F, i).Value
IE.Document.all("butAdd").Click
If IE.Document.Title = " PestPac - Maintain Notification Locations" Then
IE.Document.getElementById("Name").Value = name
IE.Document.getElementById("Address").Value = address
IE.Document.getElementById("City").Value = city
IE.Document.getElementById("State").Value = state
IE.Document.getElementById("Zip").Value = zip
IE.Document.getElementById("Phone").Value = phone
IE.Document.getElementById("Distance").Value = "0.1"
IE.Document.all("butAdd").Click
Exit For
Next i
End Sub
您需要在
退出
后的If
语句末尾添加End If
语句。如果希望添加一个Else
,也可以在文档标题为其他内容时执行不同的操作
谢谢,我现在来看看。