+ Reply to Thread
Results 1 to 16 of 16

Excel Sheet updates Exchange Rates from a Web Page

  1. #1
    Registered User
    Join Date
    05-24-2018
    Location
    Canada
    MS-Off Ver
    Windows 7
    Posts
    35

    Question Excel Sheet updates Exchange Rates from a Web Page

    Hi all,

    I am trying to connect an excel sheet with the following webpage (can't paste the URL since I am new in the forum):
    Bank of Canada website >> Home >> Statistics >> Exchange Rates >> Daily Rates

    So my initial logic was to go to the Data tab > New Query > From Other Sources > From Web. I input the URL then select only the "Table 0" and Load the data in my existing Worksheet.

    The problem is that tomorrow, the date will change in the website and the data won't update in my excel sheet. I am not sure why...

    Anyone?

    Thank you in advance!

  2. #2
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Excel Sheet updates Exchange Rates from a Web Page

    No links - but you should be able to upload a file

    go to go advanced and look for the manage attachments link
    then upload a desensitized version.
    that would save anyone looking at this some effort/allow them to know a solution works.
    If you want something done right... find a forum and ask an online expert.

    Time flies like an arrow. Fruit flies like a banana.

  3. #3
    Registered User
    Join Date
    05-24-2018
    Location
    Canada
    MS-Off Ver
    Windows 7
    Posts
    35

    Re: Excel Sheet updates Exchange Rates from a Web Page

    Quote Originally Posted by scottiex View Post
    No links - but you should be able to upload a file

    go to go advanced and look for the manage attachments link
    then upload a desensitized version.
    that would save anyone looking at this some effort/allow them to know a solution works.
    Really doesnt allow me to , the manage attachments dropdown has nothing ... its blank.

  4. #4
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Excel Sheet updates Exchange Rates from a Web Page

    it isn't a drop down, it is a link.

    This process doesn't work for you?

    https://www.excelforum.com/faq.php?d...l&titlesonly=0

  5. #5
    Registered User
    Join Date
    05-24-2018
    Location
    Canada
    MS-Off Ver
    Windows 7
    Posts
    35

    Re: Excel Sheet updates Exchange Rates from a Web Page

    nope it doesn't... plus I cant even quick reply your comment since it has a URL...

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Excel Sheet updates Exchange Rates from a Web Page

    I assume you have Get&Transform or PowerQuery, from your description in your initial post.

    If so...

    Use following url, use basic anonymous access.
    Please Login or Register  to view this content.
    Once data is brought in. Click on observations (list).
    This will expand records. Now convert list into table using "List tools".
    Use button found at top of column to expand. Then again expand for ALL of FX columns to see data within.
    Note: You can create custom function to do this as well.

    Once that's done, filter out dates to exclude ranges that you don't need (json response has data from 2017-01 to current).
    Demote headers to first row. Then transpose entire table.

    Promote first row back to header. This will mirror structure of table found below.
    https://www.bankofcanada.ca/rates/ex...xchange-rates/

    Once satisfied with result, load it onto worksheet. You can hit Refresh All to bring in new data.

    Sample image of result below (just kept few FX codes).
    0.JPG

    Edit: Alternately if you have Excel 2013 or later, you can use /xml instead of /json and use WEBSERVICE() and FILTERXML() functions to bring in data.
    Edit2: In addition to above, you should add argument, "?recent=5" at the end to limit number of records returned.
    Ex:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by CK76; 08-10-2018 at 05:11 PM.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  7. #7
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Excel Sheet updates Exchange Rates from a Web Page

    API Documentation for Bank of Canada
    https://www.bankofcanada.ca/valet/docs

  8. #8
    Registered User
    Join Date
    05-24-2018
    Location
    Canada
    MS-Off Ver
    Windows 7
    Posts
    35

    Re: Excel Sheet updates Exchange Rates from a Web Page

    WOW, amazing. Never thought of going in the documentation link and using the json/xml URL for the link.
    Now I just need to wait one more day and see if the rate for the most recent day will appear.

  9. #9
    Registered User
    Join Date
    05-24-2018
    Location
    Canada
    MS-Off Ver
    Windows 7
    Posts
    35

    Re: Excel Sheet updates Exchange Rates from a Web Page

    Quote Originally Posted by CK76 View Post
    API Documentation for Bank of Canada
    So unfortunately it did not work when I opened my excel worbook today even after refreshing the data. I had selected only Aug 10th with 5 different currencies yesterday and hoped that it would be Aug 13th today with the same currency but it didnt. the data remained the same as yesterday

  10. #10
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Excel Sheet updates Exchange Rates from a Web Page

    Hmm? I refreshed the sample file that I did and it worked fine.

    0.JPG

    See attached sample file (you will need Excel 2013 or later I believe).
    Attached Files Attached Files

  11. #11
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Excel Sheet updates Exchange Rates from a Web Page

    Oh, I forgot to mention. You should remove last step in the query editor.
    It will prevent query from finishing with new data.

  12. #12
    Registered User
    Join Date
    05-24-2018
    Location
    Canada
    MS-Off Ver
    Windows 7
    Posts
    35

    Re: Excel Sheet updates Exchange Rates from a Web Page

    it actually worked now! I tweeked something but I forgot what ?
    So here are the applied steps of the queries:
    Source > Navigation > Converted to Table > Expanded Column1 > Expanded Column1.FXUSDCAD > Expanded Column1.FXGBPCAD > Expanded Column1.FXEURCAD > Expanded Column1.FXJPYCAD > Expanded Column1.FXMYRCAD > Removed Columns (I removed the other currencies I didint need) > Demoted Headers > Transposed Table > Promoted Headers

    does that seem similar to you queries ?
    the only way I found to request only the 5 most recent dates and therefore the daily rate is to include the "?recent=5". IT didnt work initially because i filtered the dates and this will only keep the dates filtered but not feed the new ones. I dont think there is a workaround within excel appart from modifiying the source URL data...
    Last edited by ismafoot; 08-15-2018 at 09:01 AM.

  13. #13
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Excel Sheet updates Exchange Rates from a Web Page

    You could add variable within M, using Advanced Query Editor.
    Though it's probably faster to query with "?recent=5"

    Ex: This will return previous week's Monday's date.
    Please Login or Register  to view this content.
    Then at location where you apply date filter...
    replace #date() part with startDate variable.
    Please Login or Register  to view this content.

  14. #14
    Registered User
    Join Date
    05-24-2018
    Location
    Canada
    MS-Off Ver
    Windows 7
    Posts
    35

    Re: Excel Sheet updates Exchange Rates from a Web Page

    DAMN! awesome thank you.

    one more question on this: if i wanted to copy paste the workbook, will the query and connection be copied as well ? In other words, will the whole process be transferred into the copied workbook without me doing anything ?

  15. #15
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,887

    Re: Excel Sheet updates Exchange Rates from a Web Page

    Yes, as long as you copy entire query table (from sheet). It will automatically copy over associated queries.

    Edit: Or copying workbook, saveas, copying sheet containing query table etc, all replicates underlying queries along with table.

  16. #16
    Registered User
    Join Date
    05-24-2018
    Location
    Canada
    MS-Off Ver
    Windows 7
    Posts
    35

    Re: Excel Sheet updates Exchange Rates from a Web Page

    Thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Pulling Exchange Rates into Excel in 2017? How?
    By jessdaddy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-18-2017, 10:00 AM
  2. VBA Function - Exchange Rates
    By skankingpigeon in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-08-2016, 06:53 PM
  3. Exchange rates display
    By akhmoud in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-02-2013, 02:02 AM
  4. [SOLVED] Update exchange rates in Excel with the content from the Internet
    By Even in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-12-2013, 08:41 AM
  5. [SOLVED] Calculating multiple exchange rates
    By Merlinti in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 08-20-2012, 03:42 PM
  6. Formula for exchange rates
    By msincome in forum Excel General
    Replies: 1
    Last Post: 03-29-2011, 03:14 AM
  7. CDN/US closing exchange rates today to 5 yrs ago
    By Xx7 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-06-2011, 06:25 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1