How do I input a Flexible URL in Data Scraping

LVSunsFAN

New Member
Joined
Mar 14, 2021
Messages
2
Office Version
  1. 2007
Platform
  1. Windows
I am scraping data for an NBA scores and point spread spreadsheet.
Usually I get it from the website on the day itself, which would be
But sometimes I have to go back to a previous day, like
NBA Basketball Scores - DonBest.com (not that the 20210313 in the address signifies the date, 2021/03/13)

The code for the scraping part is
VBA Code:
    Range("BK3").Select
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;https://legacy.donbest.com/nba/scores/", Destination:=Range("$BK$3"))
        .Name = "scores_2"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlEntirePage
        .WebFormatting = xlWebFormattingNone
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With

Is there a way for me to paste the web address into another cell, say BG3, then change that 3rd programming line
VBA Code:
 "URL;https://legacy.donbest.com/nba/scores/", Destination:=Range("$BK$3"))
into something that automatically makes the web address whatever cell BG3 says? So
VBA Code:
"URL;whatever cell BG3 says", Destination:=Range("$BK$3"))

Thanks!
 
Last edited by a moderator:

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Try...

VBA Code:
"URL;" & Range("BG3").Value, Destination:=Range("$BK$3"))

Hope this helps!
 
Upvote 0
Solution

Forum statistics

Threads
1,214,957
Messages
6,122,472
Members
449,087
Latest member
RExcelSearch

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