Solved

Excel Web Data

Posted on 2013-01-06
7
239 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.
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…

785 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