score:0
the function getelementsbytagname()
requires a tag name only as parameter:
e.g. getelementsbytagname("div")
try getelementsbyclassname()
instead:
getprice = trim(doc.getelementsbyclassname("price").item.innertext)
score:0
there were a few issues with the above code.
issue 1
getprice = trim(doc.getelementsbytagname("div class="price" itemprop="price"").innertext)
this:
div class="price" itemprop="price"
isn't a tagname. tagnames are things like input, img, anchors, etc. however, we can see the class
attribute for the price element you are interested in. we can change how we select this element by doing:
getprice = trim(doc.getelementsbyclassname("price")(0).innertext)
you may notice (0)
at the end of the element selection. this is to indicate which element is being selected of the price classname collection. getelementsbyclassname returns multiple elements, the first element being 0.
issue 2
worksheets("sheet1").range(c1).value = getprice
i don't c1
referenced anywhere. one way to reference a specific cell, is to use a string to represent the range. from your code this becomes:
worksheets("sheet1").range("c1").value = getprice
Source: stackoverflow.com
Related Query
- How to pull data from a website with Excel VBA
- pull data from website using VBA excel multiple classname
- Scraping data from website with css selectors excel vba
- VBA - How to download .xls from website and put data into excel file
- How to remove subtotal from a excel pivot-table with mutiple data fields useing vba
- How to import data from Google Sheets into Excel with VBA
- How to scrape data from Bloomberg's website with VBA
- Get data from website screen to Excel with form - VBA
- How would I use VBA to automatically populate an excel worksheet with data from the pivot table of a separate excel workbook?
- How to pull data from a row in Access with VBA
- how to count the number of rows with data from a specific cell in excel vba
- How to grab particular data from a website to Excel with queryselectorall
- Pull data from incoming mails with specific subject into Excel file using Outlook VBA
- How do I make macro pull data from different sheets within a workbook. Excel VBA
- How can I pull data from website using vba
- Excel VBA - How to pull Data from a file in Protected view / restrict personal macros
- How to fix Excel VBA QueryTables not pulling data from a website
- How do I pull value from external website by Element ID with Excel / VBA?
- How to pull data from access to excel using vba by by checking a column in excel
- How to extract data from website with VBA Excel?
- How to insert (flexible) data into S/4HANA from cells in an Excel file with VBA code?
- How can I pull data from website table using vba
- How can I get selected data from a combobox on a website into Excel with Selenium VBA?
- Copy data to excel with VBA from a website using Classname
- Scraping data from a website with a dynamic array function - Excel VBA
- VBA Macro to pull data from secure website to excel
- How to pull cell values from Excel document into HTML table with VBA Macro with ForEach Loop
- How to fetch data from XML file to Excel sheet using VBA
- Using MSXML2.XMLHTTP in Excel VBA to extract large amounts of text data from website
- How do I run a Stored procedure with parameters from Excel VBA string?
More Query from same tag
- Increasing time difference between data points
- Search range for string, change values of adjacent cells
- VBA: Show Data in Cells Based on Criteria
- Code to add a sheet and rename that sheet
- Excel (Office) and C#
- Disable all dialog boxes in Excel while running VB script?
- Auto insert a dropDownList when a new row
- Converting Index Match to Another Sheet to VBA Code
- Creating tables at bookmarks in a Word document through Excel VBA from dynamic controls
- Array of ranges
- VBA Excel Forms | renamed labels and inputboxes became corrupted
- How do delete an specific page in a word document using Excel VBA?
- Compile error while declaring close
- Excel VBA, a for loop for changing a variable and pasting its result
- Copy values of a worksheet to a new workbook
- How can i show the data in specific cell?
- How to close an add-in when there are no more References to it?
- How to Print certain sheets in a workbook into PDF
- Nested if statement within a for loop
- How to fix overflow on 700K row range
- Powershell Send Key Excel
- (Excel) How can I AUTOMATE the creation of a comma separated list?
- Outlook VBA Pickfolder command to include subfolders
- MS-Word-VBA UserForm - How to run a macro from a command button to a specific location inside the document?
- Saving worksheets to CSV with Excel Formulas intact
- Adding hyperlinks and text to speaker notes section within PowerPoint using VBA
- Only allow letters in textbox for MS Access
- Get text from activeX textbox (VBA, powerpoint)
- COUNTIFS with floating criteria matching the next value in a column
- Copy multiple word documents into one new word document