Results 1 to 2 of 2

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

This is a discussion on VBA Excel data extracting from a website for different dates with same URL within the Excel Questions forums, part of the Question Forums category; 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 ...

  1. #1
    New Member
    Join Date
    Jun 2017
    Posts
    2

    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

    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

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
  •  


DMCA.com