LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run macro multiple times


I am currently using a macro that imports a text file, does some data
manipulation and then export the results to another text file.

One of the fields in the spreadsheet is a date field with a reference
value -1, -2, etc., it is here that I have my problem. I would like to
perform the calculation on today’s date (NOW()), export the results,
then NOW() -1, export the data, NOW() -2..., etc.

The macro I am using is as follows:

Sub Manual()

' Ticker Import Function
Range("A2").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"TEXT;C:\Documents and Settings\fundamental.txt", Destination:= _
Range("A2"))
..Name = "test"
..FieldNames = True
..RowNumbers = False
..FillAdjacentFormulas = False
..PreserveFormatting = True
..RefreshOnFileOpen = False
..RefreshStyle = xlInsertDeleteCells
..SavePassword = False
..SaveData = True
..AdjustColumnWidth = True
..RefreshPeriod = 0
..TextFilePromptOnRefresh = False
..TextFilePlatform = 437
..TextFileStartRow = 1
..TextFileParseType = xlDelimited
..TextFileTextQualifier = xlTextQualifierDoubleQuote
..TextFileConsecutiveDelimiter = False
..TextFileTabDelimiter = True
..TextFileSemicolonDelimiter = False
..TextFileCommaDelimiter = False
..TextFileSpaceDelimiter = False
..TextFileColumnDataTypes = Array(1)
..TextFileTrailingMinusNumbers = True
..Refresh BackgroundQuery:=False
End With

' QP Data Copy
Range("B2", Range("B2").End(xlToRight)).Copy
Selection.End(xlDown).Offset(0, 1).Select
Range(Selection, Selection.End(xlUp)).Select
ActiveSheet.Paste
Application.CutCopyMode = False

' Macro Delay (may be required while QP Data propagates)
' Application.Wait Now + TimeValue("00:00:??")

' New Worksheet Name, save as: (Now, "mmmm dd yyyy hh-mm" & " QP
FunData.xls")
Dim W As Workbook
Set W = Workbooks.Add(xlWBATWorksheet)
Range("A1").Select
W.Sheets("Sheet1").Range("A1:EH15000") = _
ThisWorkbook.Sheets("Sheet1").Range("A1:EH15000"). Value
ChDir "C:\Documents and Settings\fundamental data\"
W.SaveAs Application.WorksheetFunction.Text(Now, "mmmm dd yyyy hh-mm")
& " QP FunData.xls"

' Save and close open Workbook(1)
Dim Wb As Workbook
For Each Wb In Workbooks
If Wb.Name < ThisWorkbook.Name Then
Wb.Close savechanges:=True
End If
Next Wb

Application.Wait Now + TimeValue("00:00:20")
' Delete Ticker List
Range("A2", Range("A2").End(xlDown)).ClearContents

' Delete Data Rows
Range("B3", Range("B3").End(xlToRight).End(xlDown)).ClearConte nts

Application.Wait Now + TimeValue("00:00:05")
' Save and close open Workbook(2)
Range("A1").Select
ThisWorkbook.Save
Application.Quit

End Sub

Any suggestions (I hope I am being clear)?


Thanks


--
kriemer
------------------------------------------------------------------------
kriemer's Profile: http://www.excelforum.com/member.php...o&userid=28724
View this thread: http://www.excelforum.com/showthread...hreadid=484181

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Plotting multiple times against one date succesively for multiple Mal[_2_] Charts and Charting in Excel 1 August 25th 09 08:49 PM
macro to copy a value multiple times depending on value in adj dribler2 Excel Worksheet Functions 0 January 10th 07 12:48 AM
Can you code a macro so it runs multiple times in the same workboo dpmac Excel Discussion (Misc queries) 2 April 18th 06 07:40 PM
How can I sort multiple times Sorting data Excel Worksheet Functions 2 February 9th 06 05:22 PM
How do I add multiple times together Playhouse pm Excel Discussion (Misc queries) 1 May 12th 05 12:34 AM


All times are GMT +1. The time now is 02:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"