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

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
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,223,231
Messages
6,170,885
Members
452,364
Latest member
springate

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