Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 276
  • Last Modified:

Excel Web Data

Hi  Expert,

Need to download .DAT file from web via excel 2010.

Step 1 Put start date & End Date
Step 2 (a) Macro run – if data is available for that date then download to new sheet & then create new workbook for that particular sheet with date as its name.
Step 2 (b) Macro Run – if data is not available then go for next date.
Step 3 downloading data for next date.

As downloadable link is this…
http://nseindia.com/archives/equities/mto/MTO_04012013.DAT
where 04012013 is date (ddmmyyyy). So if we replace that with different date data will appear for that date.

Please Help Me Out In This.

Thank You
0
itjockey79
Asked:
itjockey79
  • 4
  • 2
1 Solution
 
SteveCommented:
Could you run this code (for one sheet and tell me if the format is OK)

Sub Macro1()

xx = InputBox("enter date ddmmyyyy")
Sheets.Add

    With ActiveSheet.QueryTables.Add(Connection:="URL;http://nseindia.com/archives/equities/mto/MTO_" & xx & ".DAT", Destination:=Range("$A$1"))
        '.Name = "MTO_4012012"
        .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
    End With
    Columns("A:A").Select
    Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
        Semicolon:=False, Comma:=True, Space:=False, Other:=False

End Sub

Open in new window

Download.xlsm
0
 
itjockey79Author Commented:
Sir The_Barman,

Yes code is perfect but need to add one more thing... add date column for that particular date. And need separate workbook for each & every date to create via macro as in this code it create sheets for particular date need separate for each date i.e. o1jan2013.csv, o2jan2013.csv, 3jan2013.csv......and so on.....csv(coma delimited) format.

Pls see attached file.....


Thank You
Download.xlsm
0
 
SteveCommented:
attached is file including the creation of .csv with the date added.

the file name is in format ddmmyyyy but can be ddmmmyyyy if you really need it.
Download.xlsm
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 
itjockey79Author Commented:
As Usual Mr.Perfect.......
0
 
itjockey79Author Commented:
Pls look in to my new question it same as this just download link is change..


Thank you
0
 
itjockey79Author Commented:
Sir The_barman,

will you attend my next questions in your free time & if you feel so......I am not in hurry



Thanks
0
 
Naresh PatelTraderCommented:
Hi Sir,
Happy New Year
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now