Solved

Excel Web Data

Posted on 2013-01-06
7
219 Views
Last Modified: 2013-12-28
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
Comment
Question by:itjockey79
  • 4
  • 2
7 Comments
 
LVL 24

Expert Comment

by:Steve
Comment Utility
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
 

Author Comment

by:itjockey79
Comment Utility
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
 
LVL 24

Accepted Solution

by:
Steve earned 500 total points
Comment Utility
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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Closing Comment

by:itjockey79
Comment Utility
As Usual Mr.Perfect.......
0
 

Author Comment

by:itjockey79
Comment Utility
Pls look in to my new question it same as this just download link is change..


Thank you
0
 

Author Comment

by:itjockey79
Comment Utility
Sir The_barman,

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



Thanks
0
 
LVL 8

Expert Comment

by:itjockey
Comment Utility
Hi Sir,
Happy New Year
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This collection of functions covers all the normal rounding methods of just about any numeric value.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now