Reputation: 67
The goal is to check multiple checkboxes depends on data in cell J(i) that is seperated with delimiter "|".
Example: Column J, Row (i) = SkillA|SkillB|SkillC
Checkbox: check/click this 3 skills.
At the moment I am able to select only 1 checkbox by storing only 1 id in cell J:
Cell J = SkillA
Doc.getElementById(sht.Range("J" & i)).Click
Full code:
Dim sht As Worksheet
Set sht = ThisWorkbook.Sheets("Fields")
Dim LastRow As Long
Dim i As Long
LastRow = sht.Cells(sht.Rows.Count, "A").End(xlUp).Row
Dim IE As Object
Dim Doc As HTMLDocument
Set IE = CreateObject("InternetExplorer.Application")
'--------------------------------
For i = 2 To LastRow
IE.Visible = True
IE.navigate sht.Range("A" & i).Value
Do While IE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
Set Doc = IE.document
code....
code....
Doc.getElementById("tab6").Click
Doc.getElementById(sht.Range("J" & i)).Click
Next i
IE.Quit
MsgBox "Process 100% completed"
End Sub
Upvotes: 0
Views: 192
Reputation: 84465
A little confusing but sounds like you want to use split to generate an array of values you can pass as id values for checkboxes
Dim values() As String, i As Long
values = Split(sht.Range("J" & i).Value, "|")
For i = LBound(values) To UBound(values)
On Error Resume Next
Doc.getElementById(values(i)).Click
On Error GoTo 0
Next
Upvotes: 1