Extract specific text from the table

jayymehta

New Member
Joined
Jan 3, 2018
Messages
18
I want the brand name to be extracted from a table, in a website in my excel sheet. There's this table which has information about the product's warranty, shipping and brand, which is under one single "div" element. So I'm unable to extract only the brand name, instead it extracts all the data from the table. I tried my best to code, and I think it would be solved by using IntStr or Mid function, but don't know how to use it here.

Code:
For Each objDiv In doc.getElementsByTagName("div")    If objDiv.ID = "CenterPanelInternal" Then
        For Each objh1 In objDiv.getElementsByTagName("h1")
            If objh1.className = "it-ttl" Then
                ThisWorkbook.Worksheets("Sheet1").Range("A1:N1").Value = objh1.outerText
            End If
        Next
        
        For Each objdiv2 In objDiv.getElementsByTagName("div")
            If objdiv2.className = "u-flL w29 vi-price" Then
                ThisWorkbook.Worksheets("Sheet1").Cells(3, 1).Value = objdiv2.outerText
            End If
        Next
    End If

    If objDiv.ID = "viTabs" Then       
        For Each objdiv3 In objDiv.getElementsByTagName("div")
            If objdiv3.className = "itemAttr" Then
                ThisWorkbook.Worksheets("Sheet1").Cells(3, 2).Value = objdiv3.outerText
            End If
        Next
    End If
Next

 

Some videos you may like

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Watch MrExcel Video

Forum statistics

Threads
1,122,577
Messages
5,596,996
Members
414,116
Latest member
sfullnet

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top