URL Cell Reference

zeeco

New Member
Joined
Sep 27, 2013
Messages
2
My goal is to obtain data (specifically stock information from yahoo) by using different tickers **in cell B1**.

FB Income Statement | Facebook, Inc. Stock - Yahoo! Finance

Above is the URL for quarterly financials for ticker "fb". I would like to put the ticker in cell B1, run the macro, and obtain the data from that page. Below is the macro I recorded. Please let me know how to make the ticker in the URL variable and based on B1.

Thanks!

Sub GetDataEx()

With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://finance.yahoo.com/q/is?s=fb", Destination:=Range("$A$10"))
.Name = "is?s=fb"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "9"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
ActiveWindow.SmallScroll Down:=-6
End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Welcome to MrExcel.

Try:

Rich (BB code):
"URL;http://finance.yahoo.com/q/is?s=" & Range("B1").Value, Destination:=Range("$A$10"))
 
Upvote 0
Thank you. That worked perfectly. Now let's say I have more text at the end of this URL string, e.g.:

FB is the ticker symbol.

"URL;No Ticker Symbol - Yahoo! FinanceFB&annual", Destination:=Range("$K$14"))


"URL;http://finance.yahoo.com/q/is?s=" & Range("B1").Value & text("&annual"), Destination:=Range("$A$10"))</pre>
^^^ Would it be something like this? I am not sure how to add the text. (Obviously missing some basics of VBA). Thanks!
 
Upvote 0
That would be:

Rich (BB code):
"URL;http://finance.yahoo.com/q/is?s=" & Range("B1").Value & "annual", Destination:=Range("$A$10"))
 
Upvote 0

Forum statistics

Threads
1,215,305
Messages
6,124,153
Members
449,146
Latest member
el_gazar

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