Scrape li tags tat shares the same class name


New Member
Mar 27, 2017
Hi Everyone. i am trying to scrape li tags that shares the same class name
the HTML cods looks like this:

<ul class="top-section-list" data-selenium="highlightList">    
                <li class="top-section-list-item">sample text# 1</li>           
                <li class="top-section-list-item">sample text# 2</li>            
                <li class="top-section-list-item">sample text# 3</li>           
                <li class="top-section-list-item">sample text# 4</li>            
                <li class="top-section-list-item">sample text# 5</li>     
my current code

Sub GetData()
    Dim objIE As InternetExplorer
    Dim itemEle As Object
    Dim data As String
    Dim y As Integer
    Set objIE = New InternetExplorer
    objIE.Visible = True
    objIE.navigate "someWebsite"
    Do While objIE.Busy = True Or objIE.readyState <> 4: DoEvents: Loop
    y = 1
    For Each itemEle In objIE.document.getElementsByClassName("top-section-list")
    data = itemEle.getElementsByTagName("li")(0).innerText
        y = y + 1
    data = Range("A1").Value
End Sub
only writes to cells A1: "sample text# 1"
how can i have all the tags to be written to cell A1?
desired result would be cell A1:
sample text# 1
sample text# 2
sample text# 3
sample text# 4
sample text# 5

Any help will be great

Some videos you may like

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Latest member

This Week's Hot Topics

  • help please
    SORRY NOT ANY GOOD AT EXCEL SO HELP WOULD BE MUCH APPRECIATED this formula is in a sheet called ignore...
  • two formulas needed
    Hello, I'll try my best to explain this: First formula needed in Sheet1 cell A2: If Sheet1 cell B2 = Sheet2 cell B2 then return a 1. If not then...
  • Dynamic Counts
    Good afternoon, we are tidying up some data & the data seems to be growing quicker than we are tidying it up! What we confirm (by reviewing it...
  • Help Excel formula eliminate duplicate values and keep only 2 identical rows.
    as picture below column A has a duplicate value. but the values are not the same as the rule. sometimes 4 rows, sometimes 10 rows or 7 or 9...
  • Macro Compile Error Sub or Function not defined
    Hello, I am trying to run macros from a validation list, all macros have been created and run perfectly on there own but I'm getting a compile...
  • Last row combined with Current Region VBA
    I'm generally happy finding the last row of data through something like Lastrow = Cells(Rows.Count, "D").End(xlUp) but I don't always receive data...