VBA - Importing Win/Loss record is being converted to date...

iamjmks

New Member
Joined
Dec 5, 2017
Messages
5
I'm scraping football score predictions that include a "Season to date (STD)" Win-Loss record. I haven't figured out how to tell excel that "2-4" isn't Feb 4th. Snipet of code below. My question is about the first line inside the For loop. I've also tried Cstr( ) instead of the '& "'
weeksht is a worksheet variable
rNum and cNum are the row and column counters
i is another counter
htmlElement is an object.
stdSpreadHome is a string containing the Class name.

The code works fine, it's just the formatting of the value that is the problem. I need the first line under the For to return "2-4", not "2/4/20". I can't format the destination cell outside the macro because it also creates the worksheet.

Thanks


VBA Code:
Set htmlElement = ie.document.getElementsByClassName(stdSpreadHome)
            
    For Each n In htmlElement
        weekSht.Cells(rNum, cNum).Value = htmlElement(i).innerText & ""
        rNum = rNum + 1
        i = i + 1
    Next
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Anthony47

Well-known Member
Joined
Mar 29, 2006
Messages
2,226
Try this modification:
VBA Code:
weekSht.Cells(rNum, cNum).Value ="'" & htmlElement(i).innerText & ""
This add the text identifier before the InnerText

Bye
 

Forum statistics

Threads
1,141,059
Messages
5,704,034
Members
421,323
Latest member
Exidous

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
Top