2016-03-31 3 views
0

これはコードブロックの真中で、各セルにアクセスしてその値を変数に転送するためのループを追加したものです。オンラインフォームに記入するためのマクロを作成すると、ループが正しく設定されない

私は、IEオブジェクトを作成し、Webサイトにアクセスするなどのコード部分を省略しました。これは正しく動作しているようです。ループは私には分かりません。

変更する必要があるのは何ですか?

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 

答えて

0

あなたはExit for後にIf文の末尾にEnd Ifステートメントを追加する必要があります。また、ドキュメントのタイトルが何か他のものであれば、別のことをしたい場合はElseを追加することもできます。

https://msdn.microsoft.com/en-us/library/752y8abs.aspx

+0

ありがとう、私は今それを見ようとしています。 –

関連する問題