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

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
This is answered on StackOverflow, see above link
 
Upvote 0
Solution

Forum statistics

Threads
1,214,606
Messages
6,120,497
Members
448,967
Latest member
visheshkotha

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