Keeps overwriting my output

SKPork

New Member
Joined
Feb 11, 2021
Messages
4
Office Version
  1. 2019
Platform
  1. Windows
  2. Web
I am scraping price data from websites and although I can get the exact output I am looking for in the "Immediate" window, when I try to send it to a worksheet, it overwrites the cells with earlier data output with the last output.

Please help!!

Option Explicit
Private cd As Selenium.ChromeDriver

Sub WeeklyPrices()

' Open Chrome

Dim cd As Selenium.ChromeDriver
Dim RowNum As Integer, ColNum As Integer
Set cd = New Selenium.ChromeDriver

Dim Count As Integer
For Count = 1 To 2

Dim Value As String
Dim names As Range
Set names = Range("c1:c2")
Dim cell As Range
For Each cell In names

cd.AddArgument "--headless"

cd.start
cd.get cell.Value

'Find Headers

Dim H2Headers As Selenium.WebElements
Dim H2Header As Selenium.WebElement

Set H2Headers = cd.FindElementsByCss("h2:nth-of-type(4)")

For Each H2Header In H2Headers

'Debug.Print H2Header.Text

RowNum = Count
ColNum = 1
Cells(RowNum, ColNum) = H2Header.Text

Next H2Header

' Find Prices

Dim OtdListItems As Selenium.WebElements
Dim OtdListItem As Selenium.WebElement

Set OtdListItems = cd.FindElementsByCss("ul:nth-of-type(4)")

For Each OtdListItem In OtdListItems

'Debug.Print OtdListItem.Text

RowNum = Count
ColNum = 2
Cells(RowNum, ColNum) = OtdListItem.Text

Next OtdListItem

Next cell

Next Count

cd.Quit

End Sub
 

Attachments

  • Capture.JPG
    Capture.JPG
    66.3 KB · Views: 4

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Keeps overwriting my output - OzGrid Free Excel/VBA Help Forum
and Keeps overwriting my output
and also Keeps overwriting my output

If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Keeps overwriting my output - OzGrid Free Excel/VBA Help Forum
and Keeps overwriting my output
and also Keeps overwriting my output

If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,214,590
Messages
6,120,421
Members
448,961
Latest member
nzskater

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