Web Form Automation: How to repeat a macro for multiple rows in a worksheet

Occasional Visitor

Sorry if this code seems elementary to some of you, but this is the first Macro I've attempted. I have a massive client list that I'm trying to import into a new website and I thought this might save me some time. Each client's information is listed in multiple cells in a row. My question: is there any way to repeat this entire macro, changing rows each time it runs? This runs flawlessly when the client info is directly in the macro but I just need to link it to a worksheet. I can't really wrap my head around it, but then I again I have no idea what I'm doing ha! Any help is appreciated. Thanks

 

 

Sub Clients()

 

Dim obj As New WebDriver
obj.Start "edge", ""
obj.Get "Website"

Dim Password As Object

obj.FindElementByName("email").SendKeys ("Email")
obj.FindElementByCss("input[type='password']").SendKeys ("Password")
obj.FindElementByClass("fluid").Click
obj.FindElementByCss("[href='/clients']").Click

obj.FindElementByClass("plus").Click
obj.FindElementByXPath("//input[@name='firstName'][2]").SendKeys ("A1")
obj.FindElementByName("lastName").SendKeys ("B1")
obj.FindElementByName("businessName").SendKeys ("C1")
obj.FindElementByClass("fluid").Click

obj.FindElementByXPath("//input[@class='prompt']").SendKeys ("D1")
obj.FindElementByClass("E1").Click
obj.FindElementByCss("button[type='submit']").Click

obj.FindElementByCss("input[placeholder='Email']").SendKeys ("F1")
obj.FindElementByName("phone").SendKeys ("G1")
obj.FindElementByCss("button[type='submit']").Click

obj.FindElementByCss("a[style='cursor: pointer; margin-top: 0em; font-family: Roboto; font-size: 14px; font-weight: 300;']").Click

 

End Sub

0 Replies