Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
I need to import financial data from 251 days, and wondered if there is a
script or method that I can use to do this, so that I dont have to repeat "import external data" 250 times? |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
sub Get Data()
Dim bk as workbook Dim sPath as String, i as long Dim sName as String sPath = "C:\Myfiles\" sName = Dir(sPath & "*.xls") do while sName < "" set bk = Workbooks.Open( Filename:=sPath & sName) bk.Worksheets(1).Range("A1").CurrentRegion.Copy _ Destination:=ThisWorkbook.Worksheets(1) .cells(rows.count,1).End(xlup)(2) bk.Close Savechanges:=False sName = dir() Loop end sub -- Regards, Tom Ogilvy "Joel" wrote: You need to write you own VBA excel macro It wuld look somethin like this sub Get Data() PrefixFileName = "PrefixFilename" for i = 1 to 251 MyfileName = Prefixfilename + Cstring(i) ' converts integer i to a string Workbooks.Open Filename:=MyfileName, ReadOnly:=True ' Removed pathname from file name so it can be referenced in this program. 'Basic doesn't like the full pathname???? stupid microsoft Do While (1) CharPosition = InStr(MyfileName, "\") If CharPosition 0 Then MyfileName = Mid(MyfileName, CharPosition + 1) Else Exit Do End If Loop Cells("A1").Copy _ Destination:=Workbooks(MyWorkbook).Worksheets (MyWorksheetName). _ Range("F2"). _ Offset(rowOffset:=0, columnOffset:=0) Next i end sub "Tommy" wrote: I need to import financial data from 251 days, and wondered if there is a script or method that I can use to do this, so that I dont have to repeat "import external data" 250 times? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Importing multiple files | Excel Discussion (Misc queries) | |||
importing multiple .dat files! | Excel Worksheet Functions | |||
Importing from multiple Excel files | Excel Discussion (Misc queries) | |||
importing multiple text files URGENT!!! HELP | Excel Worksheet Functions | |||
importing multiple text files??? | Excel Discussion (Misc queries) |