Home |
Search |
Today's Posts |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
xls files are opened in excel, not imported. Define import.
You can gather the filenames using the dir command Dim wkbk as Workbook, fName as String fName = Dir("C:\Myfolder\Unit Cost*.xls") if fName < "" then do set wkbk = workbooks.Open("C:\Myfolder\" & fName) wkbk.worksheets(1).copy After:=thisworkbook.worksheets( _ ThisWorkbook.worksheets.count) wkbk.close Savechanges:=False fName = dir() loop until fName = "" end if -- Regards, Tom Ogilvy "JT" wrote in message ... I want to import a number of files into Excel with a macro but I'm not sure where to start. I want to kick off the macro in Excel. The macro should go to another drive and a specific folder (based on date) and import any file with a name that begins with Unit Cost. The file names will be like Unit Cost 1.xls, Unit Cost 3.xls, Unit Cost 7.xls. The will be in sequential order but the number at the end of the file (1, 3, 7) will not be one after another. There could (and probably will) be gaps in the numbers. Once the macro gets to the correct folder, it should read down the list of files and inport each one that begins with Unit Cost. Thanks for the help. |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Importing and merging Excel files by using a macro | Excel Discussion (Misc queries) | |||
Macro for importing text files but the file name changes | Excel Worksheet Functions | |||
importing .prn files | Excel Discussion (Misc queries) | |||
Having trouble importing CSV files with a macro | Excel Programming | |||
Importing files | Excel Programming |