+ Reply to Thread
Results 1 to 16 of 16

VB Script to Fetch "Effective Date" from Website?

  1. #1
    Forum Contributor
    Join Date
    12-30-2009
    Location
    US
    MS-Off Ver
    Excel 2003, 2010, 2016, 2019, & Office 365
    Posts
    194

    VB Script to Fetch "Effective Date" from Website?

    Hi,

    I am trying to make a simple script that when run will populate cell A1 with the text: "Rates shown are effective xx/xx/xx" which is displayed on this website: https://www.wsj.com/market-data/bonds

    Is there a way to pull just this text in? I have a script that pulls the rates table in, which works great, but I need a way to import the effective date to make sure the data from the website if correct.

  2. #2
    Forum Contributor
    Join Date
    12-30-2009
    Location
    US
    MS-Off Ver
    Excel 2003, 2010, 2016, 2019, & Office 365
    Posts
    194

    Re: VB Script to Fetch "Effective Date" from Website?

    I guess I should ask, should it be incorporated into my script for the rate data that is pulled? If so, Here is my script:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    12-30-2009
    Location
    US
    MS-Off Ver
    Excel 2003, 2010, 2016, 2019, & Office 365
    Posts
    194

    Re: VB Script to Fetch "Effective Date" from Website?

    Is there a way to gather the info from the site source code maybe?

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,572

    Re: VB Script to Fetch "Effective Date" from Website?

    Which date are you trying to pull? I can see both 11 and 12 July as headers at various points on the page - which one do you need?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  5. #5
    Forum Contributor
    Join Date
    12-30-2009
    Location
    US
    MS-Off Ver
    Excel 2003, 2010, 2016, 2019, & Office 365
    Posts
    194
    I need the 11th, it should be the one a day behind, since the rates are for the previous day.
    Last edited by AliGW; 07-12-2019 at 02:13 AM. Reason: Please don't quote unnecessarily!

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,572

    Re: VB Script to Fetch "Effective Date" from Website?

    OK, but please clarify where on the page you wish to take it from. There are several dates - you need to be specific (which table?).

  7. #7
    Forum Contributor
    Join Date
    12-30-2009
    Location
    US
    MS-Off Ver
    Excel 2003, 2010, 2016, 2019, & Office 365
    Posts
    194
    My apologies, I think it's table 1. I'm importing the rates from table 1 (Libor Rates) and want that corrosponding effective date included with my data.
    Last edited by AliGW; 07-12-2019 at 02:22 AM. Reason: Please don't quote unnecessarily!

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2406 (Windows 11 23H2 64-bit)
    Posts
    81,572

    Re: VB Script to Fetch "Effective Date" from Website?

    Thanks - hopefully one of our VBA experts will be able to tell you how to grab that from the web page.

    Administrative Note:

    Please don't quote whole posts, especially when you are responding to the one immediately preceding your own - it's just clutter. It's OK to quote if you are responding to a post out of sequence, but limit quoted content to a few relevant lines that makes clear to whom and what you are responding. Thanks!

    For normal conversational replies, try using the QUICK REPLY box below.

  9. #9
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Cool Hi ! Try this ‼


    Quote Originally Posted by Rick-O-Shay View Post
    Is there a way to gather the info from the site source code maybe?
    A starter demonstration :

    PHP Code: 
    Sub Demo()
            
    Dim L&
        
    With CreateObject("WinHttp.WinHttpRequest.5.1")
            .
    Open "GET""https://www.wsj.com/market-data/bonds"False
            
    .setRequestHeader "DNT""1"
            
    .send
         
    If .Status 200 Then
             L 
    InStr(.responseText"Rates shown are effective")
             If 
    L Then MsgBox Mid(.responseTextLInStr(L, .responseText"</") - L)
         
    End If
        
    End With
    End Sub 
    Do you like it ? So thanks to click on bottom left star icon « Add Reputation » !

  10. #10
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: VB Script to Fetch "Effective Date" from Website?

    Another little variation of the great code of Marc L
    Please Login or Register  to view this content.
    < ----- Please click the little star * next to add reputation if my post helps you
    Visit Forum : From Here

  11. #11
    Forum Contributor
    Join Date
    12-30-2009
    Location
    US
    MS-Off Ver
    Excel 2003, 2010, 2016, 2019, & Office 365
    Posts
    194

    Re: VB Script to Fetch "Effective Date" from Website?

    Marc L,

    That little bit did it. But is there a way to make a slight modification? How can I incorporate it into my existing script so that it works at the same time? Also, instead of a messagebox, I want the result to display in a specific cell, such as A12 in my current situation.

    Sorry, I'm still learning vb scripting.

    Edit**

    I think I was able to just incorporate the code into my existing script, now I just need to display results in a cell.
    Last edited by Rick-O-Shay; 07-12-2019 at 11:52 AM.

  12. #12
    Forum Expert
    Join Date
    04-23-2009
    Location
    Matrouh, Egypt
    MS-Off Ver
    Excel 2013
    Posts
    6,892

    Re: VB Script to Fetch "Effective Date" from Website?

    Just replace
    Please Login or Register  to view this content.
    with
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    12-30-2009
    Location
    US
    MS-Off Ver
    Excel 2003, 2010, 2016, 2019, & Office 365
    Posts
    194

    Re: VB Script to Fetch "Effective Date" from Website?

    Thank you both! This made my day!!

  14. #14
    Forum Contributor
    Join Date
    12-30-2009
    Location
    US
    MS-Off Ver
    Excel 2003, 2010, 2016, 2019, & Office 365
    Posts
    194

    Re: VB Script to Fetch "Effective Date" from Website?

    One last question on this:

    Everything worked when I updated my script while I was at work. We use Excel 2010 at my work. I then emailed the file to myself and tried to open the exact same file at home and when I run the script it errors. I use Excel 2016. I don't understand why a version change would break the script.

    Error Code: System Error &H80072F7D (-2147012739). An error occurred in the secure channel support.

  15. #15
    Forum Expert
    Join Date
    11-24-2013
    Location
    Paris, France
    MS-Off Ver
    Excel 2003 / 2010
    Posts
    9,831

    Arrow


    If my code I have no idea as it well works on my side …

  16. #16
    Forum Contributor
    Join Date
    12-30-2009
    Location
    US
    MS-Off Ver
    Excel 2003, 2010, 2016, 2019, & Office 365
    Posts
    194

    Re: VB Script to Fetch "Effective Date" from Website?

    Here is how I have the code embedded. It works find on Excel 2010 but errors on 2016:

    Please Login or Register  to view this content.

+ 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. vba script help for pivot table date filter - "Before"
    By nij in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 09-11-2017, 06:23 AM
  2. Replies: 1
    Last Post: 01-22-2016, 09:21 AM
  3. Script not copying data from "Emails" sheet to "New Sheet" - Run time error: Object
    By methuselah90 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-08-2014, 03:22 PM
  4. [SOLVED] Script to save to folder in "v:\dept2", confirm file saved, then delete from "v:\dept1"
    By ks100 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-28-2014, 11:42 AM
  5. Date format of just "st" "nd" "rd" and "th" with text included
    By notrandom in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 08-10-2013, 05:45 PM
  6. Return "green", "yellow" or "red" from date/age and priority ranking
    By Cantaloop in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-04-2013, 12:12 AM
  7. HYPERLINK("website/"Cell.Text"website, A4)
    By keepstar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 02-17-2010, 05:17 PM

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