-
Solved: Need help with copying data from another workbook
I'm a newb, struggling with copying data from another workbook. Can someone help me out
OpenFile = Application.GetOpenFilename(FileFilter:="Excel files(*.xls), *.xls")
This code will bring up the open file prompt and after the user select the .xls file, how do I copy all data on a worksheet called Data to the active workbook that i'm working on?
-
GetOpenFilename only returns the filename. You'll need to open the workbook, then copy the sheet. Something like this:
[VBA]
Dim myWorkbook As Excel.Workbook
Set myWorkbook = Workbooks.Open(OpenFile)
myWorkbook.Sheets("Data").Copy After:=ActiveWorkbook.Sheets(1)
[/VBA]
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules