I am trying to get the code to loop through the list once and then when it is finished with that list repeat the process again, but with the next item another item group.
in the code below there is a TerritoryGroupListRes(0). when it goes through all the items in AddingProductsToList. I want TerritoryGroupListRes(0) to go to the next one in that array
Dim a As Integer
For a = 0 To AddingProductsToList.count - 1
'filters
Application.Wait Now TimeValue("00:00:1")
.FindElementByName("qbe0_1.20").Clear
.FindElementByName("qbe0_1.20").SendKeys ("12/31/2040")
'territory
.FindElementByName("qbe0_1.46").Clear
.FindElementByName("qbe0_1.46").SendKeys (TerritoryGroupListRes(0))
'item grp 01 filter
.FindElementByName("qbe0_1.36").Clear
.FindElementByName("qbe0_1.36").SendKeys (AddingProductsToList(a))
.FindElementById("hc_Find").Click
'click on item after filters
.FindElementByXPath("//*[@id='G0_1_R0']/td[1]/div/input").Click
.FindElementByXPath("//*[@id='G0_1_R0']/td[1]/div/input").ClickDouble
'expire the territory
Application.Wait Now TimeValue("00:00:2")
.FindElementByXPath("//*[@id='G0_1_R1']/td[1]/div/input").Click
.FindElementByXPath("//*[@id='G0_1_R1']/td[4]/div/input").Clear
.FindElementByXPath("//*[@id='G0_1_R1']/td[4]/div/input").SendKeys(ExpireDate).Value
.FindElementByXPath("//*[@id='G0_1_R1']/td[1]/div/input").ClickContext
'for testing, will need to change to id=hc_OK"
.FindElementById("hc_Cancel").Click
Next a
CodePudding user response:
As I typed that out I thought of nesting it: as so
Dim a As Integer
Dim b As Integer
For a = 0 To TerritoryGroupListRes.count - 1
For b = 0 To AddingProductsToList.count - 1
'filters
Application.Wait Now TimeValue("00:00:1")
.FindElementByName("qbe0_1.20").Clear
.FindElementByName("qbe0_1.20").SendKeys ("12/31/2040")
'territory
.FindElementByName("qbe0_1.46").Clear
.FindElementByName("qbe0_1.46").SendKeys (TerritoryGroupListRes(a))
'item grp 01 filter
.FindElementByName("qbe0_1.36").Clear
.FindElementByName("qbe0_1.36").SendKeys (AddingProductsToList(b))
.FindElementById("hc_Find").Click
'click on item after filters
.FindElementByXPath("//*[@id='G0_1_R0']/td[1]/div/input").Click
.FindElementByXPath("//*[@id='G0_1_R0']/td[1]/div/input").ClickDouble
'expire the territory
Application.Wait Now TimeValue("00:00:2")
.FindElementByXPath("//*[@id='G0_1_R1']/td[1]/div/input").Click
.FindElementByXPath("//*[@id='G0_1_R1']/td[4]/div/input").Clear
.FindElementByXPath("//*[@id='G0_1_R1']/td[4]/div/input").SendKeys(ExpireDate).Value
.FindElementByXPath("//*[@id='G0_1_R1']/td[1]/div/input").ClickContext
'for testing, will need to change to id=hc_OK"
.FindElementById("hc_Cancel").Click
Next b
Next a
If someone has a better solution or to do it better, all ears.