![]() |
|
|
|
#1
|
|||
|
|||
|
Hello gbaker -
Below is a quick example of copying data from external text files into a master Excel Workbook. Code:
Sub ImportMonthlySales()
Dim myTextFile As Workbook
Dim OpenFiles() As Variant
OpenFiles = GetFiles()
Application.ScreenUpdating = False
For i = 1 To Application.CountA(OpenFiles)
Set myTextFile = Workbooks.Open(OpenFiles(i))
myTextFile.Sheets(1).Range("A1").CurrentRegion.Copy
Workbooks(1).Activate
Workbooks(1).Worksheets.Add
ActiveSheet.Paste
Application.CutCopyMode = False
myTextFile.Close
Next i
Application.ScreenUpdating = True
End Sub
Private Function GetFiles() As Variant
GetFiles = Application.GetOpenFilename(Title:="Select File(s) to import", MultiSelect:=True)
End Function
|
|
#2
|
|||
|
|||
|
Hi,
Thanks for the help. I need to have the code go to a specific folder as soon as it runs and be able to open multiple files, copy and paste the information to a master table. |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Run a macro on multiple docx. files
|
Peter Carter | Word VBA | 27 | 12-15-2022 04:10 PM |
| Error when trying to open .docx after I run a macro to copy data between tables in two documents | reesjordan | Word VBA | 3 | 06-18-2015 12:28 AM |
| Macro to copy cell info to multiple documents | Patrick Innes | Word VBA | 2 | 02-18-2015 08:38 PM |
how to copy some information from one excel file to another excel file
|
tomlam | Excel Programming | 4 | 10-01-2013 03:06 PM |
looking for macro for multiple files
|
bolk | Word | 3 | 05-03-2011 05:46 AM |