mardi 4 décembre 2018

VBA checking multiple html checkboxes on web

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




Aucun commentaire:

Enregistrer un commentaire