Dynamic Web Query Refresh

Nittanyblu

New Member
Joined
Feb 27, 2020
Messages
1
Office Version
  1. 365
Platform
  1. Windows
How do I set up a web query in excel and make it dynamic for yahoo finance? I’d like to have a reference cell for the ticker symbol of which the web query references this cell. Therefore when the query is refeshed it reflects the stock ticker in the reference cell.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Here's one way:

• Put a stock symbol in a cell and name that cell RefSymbol
(I put BAC in that cell)

• Create a blank query in Power Query
• Edit the query in the Advanced Editor and replace ALL of the M-Code with this:
Code:
let
    Symbol = Excel.CurrentWorkbook(){[Name="RefSymbol"]}[Content]{0}[Column1],
    BaseURL = "https://finance.yahoo.com/quote/SYMBOL?p=SYMBOL",
    URL = Text.Replace(BaseURL,"SYMBOL",Symbol),
  
    Source = Web.Page(Web.Contents(URL)),
    #"Filtered Rows" = Table.SelectRows(Source, each ([ClassName] = "W(100%)")),
    #"Removed Other Columns" = Table.SelectColumns(#"Filtered Rows",{"Data"}),
    #"Added Custom" = Table.AddColumn(#"Removed Other Columns", "Symbol", each Symbol),
    #"Expanded Data" = Table.ExpandTableColumn(#"Added Custom", "Data", {"Column1", "Column2"}, {"Column1", "Column2"}),
    Result = if Table.IsEmpty(#"Expanded Data") = false
            then #"Expanded Data"
            else null
in
    Result

• Close the query and load the data wherever you'd like.

As of this time, that query returned:
Code:
Column1             Column2         Symbol
Previous Close      30.63         BAC
Open                29.55         BAC
Bid                 28.45 x 1800  BAC
Ask                 28.74 x 900   BAC
Day's Range         28.91 - 30.30 BAC
52 Week Range       26.21 - 35.72 BAC
Volume              117,103,804   BAC
Avg. Volume         46,852,875    BAC

Is that something you can work with?
 
Upvote 0
I go this to work with one ticker symbol. But I have no idea how to get this to work with many symbols with one query. Could that be done with many symbols in one query? Would it be possible to have the reference cells down Column A and have the Data in rows? I have upload an example of how I think it should look like. I have home an student 2013 version of Excel.

Thanks in advance for your time and brain energy.
 

Attachments

  • IMAGE.jpg
    IMAGE.jpg
    73.8 KB · Views: 11
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,988
Members
452,373
Latest member
TimReeks

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