Hi, I am new to VBA and I would to know if any of you have a macro that I can user to copy an entire worksheet from a workbook (in a specified directory) to the current workbook using VBA? - Thanks for your help.
Hi, I am new to VBA and I would to know if any of you have a macro that I can user to copy an entire worksheet from a workbook (in a specified directory) to the current workbook using VBA? - Thanks for your help.
Hello AJHWilliams,
Welcome to the Forum!
If this a one time event, you don't need VBA to do this.
1) Have both workbooks open.
2) Activate the sheet you want to copy
3) On the main menu click Edit
4) Select Move or Copy Sheet...
5) Select the workbook to copy to using the drop down To book:
6) Select where you want the copied sheet to be placed by selecting a sheet in the Before sheet: list.
7) Check the box labeled Create a copy.
Sincerely,
Leith Ross
Hi,
Thanks, but this is not a one time event. I would like to automate the process using VBA. I already have code to edit, and format the results but I am struggling with a clean simple way to import the worksheet.
Hello AJHWilliams,
This macro will let you select the workbook from the directory you choose. The worksheet you specify in the macro will copied to the workbook running the macro. The chosen workbook will be closed when the worksheet is copied or an error is encountered. You specify both the worksheet name you want to copy and the new name it will be given. The names are marked in red.
Adding the MacroPlease Login or Register to view this content.
1. Copy the macro above pressing the keys CTRL+C
2. Open your workbook
3. Press the keys ALT+F11 to open the Visual Basic Editor
4. Press the keys ALT+I to activate the Insert menu
5. Press M to insert a Standard Module
6. Paste the code by pressing the keys CTRL+V
7. Make any custom changes to the macro if needed at this time
8. Save the Macro by pressing the keys CTRL+S
9. Press the keys ALT+Q to exit the Editor, and return to Excel.
To Run the Macro...
To run the macro from Excel, open the workbook, and press ALT+F8 to display the Run Macro Dialog. Double Click the macro's name to Run it.
Sincerely,
Leith Ross
Hi Leith,
I have tried this and it works as described - many thanks! The only line it fails on is Application.ScreeenUpdating = True , I have edited this out for the moment.
Regards - Andrew.
AJHWilliams,
Leith had one to many e's
Try
VBA NoobPlease Login or Register to view this content.
_________________________________________
Credo Elvem ipsum etian vivere
_________________________________________
A message for cross posters
Please remember to wrap code.
Forum Rules
Please add to your signature if you found this link helpful. Excel links !!!
Hello there - hopefully the original author of this is still around. I'm having some trouble debugging your script using Excel 2011.
I am getting the error message: "'GetOpenFilename' of object '_Application' failed"
Is there any chance you are able to help? I'm not sure what went wrong. I resaved from .xlsx to .xls to mitigate any update-related extension issues but I'm not sure where else to go from there, as this macro is way over my head.
Ben
The problem is that the filter on the GetOpenFileName is for Windows.
Windows has established a different filter structure for Mac Excel. And their implementation doesn't work very well.
The workaround is to use the MacScript command to access AppleScript.
This conditionaly formatted code will work on both platforms.
Please Login or Register to view this content.
_
...How to Cross-post politely...
..Wrap code by selecting the code and clicking the # or read this. Thank you.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks