0

I am trying to create multiple users on a web application using Excel VBA script. Below code works fine for the first row user creation but stops at set document for the second row. Actually Web app Page redirects to a different page and I think that is causing the issue here. Can someone help me to loop the URL1 for every row here.

Sub Usercreation()
 Dim UC As Object
 Dim doc As HTMLDocument 

 Set UC = CreateObject("internetexplorer.application")
 lr = ThisWorkbook.Sheets("Data").Cells(Rows.Count, 1).End(xlUp).Row  

 UC.Visible = True
 UC.navigate "URL1"

 Do While UC.Busy
   Application.Wait DateAdd("s", 1, Now)
   DoEvents

 Loop

 For introw = 2 To lr  

 Set doc = UC.document

     doc.getElementById("FirstName").Value = ThisWorkbook.Sheets("Data").Range("A" & introw).Value
     doc.getElementById("LastName").Value = ThisWorkbook.Sheets("Data").Range("B" & introw).Value
     doc.getElementById("MobileNo").Value = ThisWorkbook.Sheets("Data").Range("C" & introw).Value
     doc.getElementById("Email").Value = ThisWorkbook.Sheets("Data").Range("D" & introw).Value
     doc.getElementById("Username").Value = ThisWorkbook.Sheets("Data").Range("E" & introw).Value
     doc.getElementById("Password").Value = ThisWorkbook.Sheets("Data").Range("F" & introw).Value
     doc.getElementById("ConfirmPassword").Value = ThisWorkbook.Sheets("Data").Range("G" & introw).Value
     doc.getElementById("Name").Value = ThisWorkbook.Sheets("Data").Range("H" & introw).Value
     doc.getElementsByClassName("btn btn-default")(0).Click

  Application.Wait DateAdd("s", 2, Now)

  UC.Quit
  Set UC = Nothing


 Next introw

End Sub

braX
  • 11,506
  • 5
  • 20
  • 33

0 Answers0