URL in cell used in VBA code to import web data

amit96

New Member
Joined
Feb 15, 2022
Messages
27
Office Version
  1. 2013
Platform
  1. Windows
Hi everybody,
I am extracting stock information from yahoo site in VBA code.
I want the URL from which the information will be taken to be in accordance with cell C5.
That is, the URL that is in cell C5 is the address from which the information will be taken to Excel.

- Now it looks like this -

With ActiveSheet.QueryTables.Add (Connection: = _
"URL; https: //finance.yahoo.com/quote/TSLA/financials? P = TSLA", Destination: = _
Range ("$ A $ 6"))
.Name = "financials? P = TSLA"
.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


The URL is now fixed. I want to change it according to the value of cell C5.

I would be happy for your help please
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
"Not working" as a response does not help your situation.

Post what the code looks like with your changes.

Make sure you also post a working example of what the code looks like when you have the address hard coded into the code. I assume you have a working example that you now want to use the value from C5 instead.
 
Upvote 0
NOT WORKING - Application.CutCopyMode = False
With ActiveSheet.QueryTables.Add(Connection:= _
"Range("C5").value", Destination:= _
Range("$A$6"))

Without quotes also does not work.
 
Upvote 0
i do have an internet connection. i dont know what the problem is
1654412371220.png
 
Upvote 0
Example:
Sheets("Sheet2").Range("C6").value
 
Upvote 0

Forum statistics

Threads
1,214,982
Messages
6,122,573
Members
449,089
Latest member
Motoracer88

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