Solved

Excel Web Data

Posted on 2013-01-06
7
232 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
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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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:itjockey
ID: 39743401
Hi Sir,
Happy New Year
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

My experience with Windows 10 over a one year period and suggestions for smooth operation
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

920 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

14 Experts available now in Live!

Get 1:1 Help Now