Web Extraction code needs a tweak

Sharid

Well-known Member
Joined
Apr 22, 2007
Messages
1,064
Office Version
  1. 2016
Platform
  1. Windows
I am trying to write this line of code so it takes the sheet to use from a Sheet + cell in excel I can do it with the class and child nods, but not for the sheet to input the data. The code is repeated for columns A to K

I know that even this is not the best, however I am limited in VBA and it does work
VBA Code:
        If element.getElementsByClassName(Sheets("Sheet20").Range("A23"))(Sheets("Sheet20").Range("B23")) Is Nothing Then ' Get CLASS and Child Nod
                wsSheet.Cells(Sheet3.Cells(Sheet3.Rows.Count, "F").End(xlUp).row + 1, "F").Value = "-" 'If Nothing then Hyphen
        Else
            HtmlText = element.getElementsByClassName(Sheets("Sheet20").Range("A23"))(Sheets("Sheet20").Range("B23")).innerText  ' Get CLASS and Child Nod
                 wsSheet.Cells(Sheet3.Cells(Sheet3.Rows.Count, "F").End(xlUp).row + 1, "F").Value = HtmlText 'return value in column
        End If

I tried this, however the data is not correct see image below, with the above code it extracts correctly, for 200+ records.

VBA Code:
   If element.getElementsByClassName(Sheets("Sheet20").Range("A23"))(Sheets("Sheet20").Range("B23")) Is Nothing Then ' Get CLASS and Child Nod
  '''#### Instead of Sheet3 I am trying to get the required sheet from SHEET20 Cell E16
                wsSheet.Cells(Sheets("Sheet20").Range("E16").Cells(Sheets("Sheet20").Range("E16").Rows.Count, "F").End(xlUp).row + 1, "F").Value = "-" 'If Nothing then Hyphen
        Else
            HtmlText = element.getElementsByClassName(Sheets("Sheet20").Range("A23"))(Sheets("Sheet20").Range("B23")).innerText  ' Get CLASS and Child Nod
  '''#### Instead of Sheet3 I am trying to get the required sheet from SHEET20 Cell E16
                 wsSheet.Cells(Sheets("Sheet20").Range("E16").Cells(Sheets("Sheet20").Range("E16").Rows.Count, "F").End(xlUp).row + 1, "F").Value = HtmlText  'return value in column
        End If

1610144485065.png
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
This is answered on StackOverflow, see above link
 
Upvote 0
Solution

Forum statistics

Threads
1,215,543
Messages
6,125,429
Members
449,223
Latest member
Narrian

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
Back
Top