title: Web Extraction code needs UPDATING, Trying to add sheet from worksheet Cell
body: <p>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 Into. The code is repeated for columns A to K</p>
  <p>I know that even this is not the best, however I am limited in VBA and it does work. I have Changed from Sheet3 to Sheet4, Also Posted Here <a href="https://www.mrexcel.com/board/threads/web-extraction-code-needs-a-tweak.1157954/" rel="nofollow noreferrer">Mr Excel</a></p>
  <p><strong>Current Code that Works</strong></p>
  <pre><code>'Sheet20 A18 + B18
  If element.getElementsByClassName(Sheets(&quot;Sheet20&quot;).Range(&quot;A18&quot;))(Sheets(&quot;Sheet20&quot;).Range(&quot;B18&quot;)) Is Nothing Then ' Get CLASS and Child Nod
      wsSheet.Cells(Sheet4.Cells(Sheet4.Rows.Count, &quot;A&quot;).End(xlUp).Row + 1, &quot;A&quot;).Value = &quot;-&quot; 'If Nothing then Hyphen in CELL
  Else
      HtmlText = element.getElementsByClassName(Sheets(&quot;Sheet20&quot;).Range(&quot;A18&quot;))(Sheets(&quot;Sheet20&quot;).Range(&quot;B18&quot;)).innerText ' Get CLASS and Child Nod
      wsSheet.Cells(Sheet4.Cells(Sheet4.Rows.Count, &quot;A&quot;).End(xlUp).Row + 1, &quot;A&quot;).Value = HtmlText 'return value in column
  End If
  </code></pre>
  <p>Current Results, still need a slight tweak in the Class and Child Nods</p>
  <p><a href="https://i.stack.imgur.com/JGK4u.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JGK4u.png" alt="Product Image 1" /></a></p>
  <p><strong>The NEW Changes I am trying to implement</strong></p>
  <p><strong>Sheet4</strong> is taken from <strong>Cell E16 on Sheet20</strong>. This will KEEP CHANGING depending on which tab is selected and therefore the data needs to go into the correct sheet. I will be using this code several times and rather that re-write it each time for each sheet. I want to change the input sheet within the code. This way I can change the class + child nods + sheet to add data too, thus enabling me to use the ONE code.</p>
  <pre><code>If element.getElementsByClassName(Sheets(&quot;Sheet20&quot;).Range(&quot;A18&quot;))(Sheets(&quot;Sheet20&quot;).Range(&quot;B18&quot;)) Is Nothing Then ' Get CLASS and Child Nod
      '''#### Instead of Sheet4 I am trying to get the required sheet from SHEET20 Cell E16
      wsSheet.Cells(Sheets(&quot;Sheet20&quot;).Range(&quot;E16&quot;).Cells(Sheets(&quot;Sheet20&quot;).Range(&quot;E16&quot;).Rows.Count, &quot;A&quot;).End(xlUp).Row + 1, &quot;A&quot;).Value = &quot;-&quot; 'If Nothing then Hyphen
  Else
      HtmlText = element.getElementsByClassName(Sheets(&quot;Sheet20&quot;).Range(&quot;A18&quot;))(Sheets(&quot;Sheet20&quot;).Range(&quot;B18&quot;)).innerText ' Get CLASS and Child Nod
      '''#### Instead of Sheet4 I am trying to get the required sheet from SHEET20 Cell E16
      wsSheet.Cells(Sheets(&quot;Sheet20&quot;).Range(&quot;E16&quot;).Cells(Sheets(&quot;Sheet20&quot;).Range(&quot;E16&quot;).Rows.Count, &quot;A&quot;).End(xlUp).Row + 1, &quot;A&quot;).Value = HtmlText 'return value in column
  </code></pre>
  <p><strong>This is the results with the new Code</strong></p>
  <p><a href="https://i.stack.imgur.com/Twhww.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Twhww.png" alt="Product Picture 2" /></a></p>
  <p><strong>Problem</strong></p>
  <p>Although the correct sheet is selected, ALL of the extracted data goes into the SAME cells overwriting and previous data, when it show go to next row, as show in the above image.</p>
  <p>'##### Edit Today 2.44 uk time ######</p>
  <p>These are the HTML classes that the code uses from sheet20, I can keep changing the classes on a button click</p>
  <p><a href="https://i.stack.imgur.com/ufzoR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ufzoR.png" alt="HTML Class" /></a></p>
  <p>This is Sheet20 Cell E16. This will Also keep changing, what i was trying to do was get the code to use which ever sheet is stated in this cell</p>
  <p><a href="https://i.stack.imgur.com/gsXTf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gsXTf.png" alt="Active Sheet" /></a></p>