Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: VBA Excel data extracting from a website for different dates with same URL

  1. #1
    New Member
    Join Date
    Jun 2017
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default VBA Excel data extracting from a website for different dates with same URL

    I need to extract website table data from this link: https://www.iexindia.com/marketdata/areaprice.aspx for different dates. The problem is that even for a different date, the URL of the website remains same as the URL for the current date, So I can not use the dynamic URL in the VBA code. I am getting data only for the current date. Any help is extremely appreciated. Thank you.

  2. #2
    New Member
    Join Date
    Jun 2017
    Posts
    2
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: VBA Excel data extracting from a website for different dates with same URL

    I am using this code but its returning data only for the current date. Please help me in creating a loop such that I can extract data for other desired dates also. The problem is that the URL is same even after changing the date, so I can not use the dynamic URL.

    Code:
    Sub Macro1() ' ' Macro1 Macro ' ' 
    Application.CutCopyMode = False
    
    Sub Macro1() ' ' Macro1 Macro ' ' 
    Application.CutCopyMode = False
    
    Application.CutCopyMode =False
    
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;https://www.iexindia.com/marketdata/areaprice.aspx", Destination:=Range( _
        "$A$1"))
    
        .Name ="areaprice"
    
        .FieldNames =True
    
        .RowNumbers =False
    
        .FillAdjacentFormulas =False
    
        .PreserveFormatting =True
    
        .RefreshOnFileOpen =False
    
        .BackgroundQuery =True
    
        .RefreshStyle = xlInsertDeleteCells
    
        .SavePassword =False
    
        .SaveData =True
    
        .AdjustColumnWidth =True
    
        .RefreshPeriod =0
    
        .WebSelectionType = xlEntirePage
    
        .WebFormatting = xlWebFormattingNone
    
        .WebPreFormattedTextToColumns =True
    
        .WebConsecutiveDelimitersAsOne =True
    
        .WebSingleBlockTextImport =False
    
        .WebDisableDateRecognition =False
    
        .WebDisableRedirections =False
    
        .Refresh BackgroundQuery:=False
    
    EndWith
    
    Rows("1:2").Select
    
    Rows("1:131").Select
    
    Range("J1").Activate
    
    Selection.Delete Shift:=xlUp
    
    ActiveWindow.LargeScroll ToRight:=-1
    
    Columns("A:L").Select
    
    Selection.Delete Shift:=xlToLeft
    
    Rows("104:313").Select
    
    Selection.Delete Shift:=xlUp
    
    Range("J103").Select
    Last edited by mole999; Jun 19th, 2017 at 08:13 AM. Reason: CODE TAGS

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
This website uses cookies
We use cookies to store session information to facilitate remembering your login information, to allow you to save website preferences, to personalise content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners.
     


DMCA.com