Solved

Excel Web Data

Posted on 2013-01-06
7
267 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 24

Expert Comment

by:Steve
ID: 38750853
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
ID: 38751877
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
ID: 38754378
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Closing Comment

by:itjockey79
ID: 38757879
As Usual Mr.Perfect.......
0
 

Author Comment

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


Thank you
0
 

Author Comment

by:itjockey79
ID: 38766497
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:Naresh Patel
ID: 39743401
Hi Sir,
Happy New Year
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article describes a serious pitfall that can happen when deleting shapes using VBA.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

623 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