Hi,
I have not clue how to do this and don't have a life time to work it out, so I am happy to pay a reasonable fee to someone who can.
I want some VBA code I can use on a button press to copy the contents of specific worksheets between two workbooks.
Main Workbook (MainWB) - .xlsm
Import Workbook (ImpWB) - .xls / .xlsx
MainWB has many worksheets. Some are placeholders for data to be imported from the ImpWB. The other worksheets reference the ones to be imported for the data/calculations.
ImpWB also has many worksheets but not all will be imported. Only data from named worksheets will be copied to the matching worksheets in the MainWB.
MainWB has button for importing data using VBA code. On Press.
1) Ask for confirmation (as data will be deleted) - Yes/No pop-up dialog box (with customisable text). Exit on No.
2) Ask for the ImpWB file name (standard Windows file open dialog box)
3) Validation check for the existence of all named worksheets in the both Workbooks - if any missing pop-up error with details of missing & the 'OK' to exit.
4) Delete any existing content/formatting (not the whole worksheet) from the named worksheets in the MainWB. Suppress all prompts.
5) For each of the named worksheets copy the entire contents (all cols/rows) from the ImpWB to the same named worksheet in the MainWB
6) For each of the named worksheets in MainDB format as a table (Table Style Medium 16) with first row as headers
7) Close the ImpWB and DO NOT save any changes.
Hide the ImpWB whilst the process is happening.
Add inline code comments to help me understand what section does what.
The named worksheets should be in a single 'reuseable' array, to allow easy adds/removes in future.
I will own the right to re-use and/or distribute the code as I see fit.
If anyones interested let me know how the commercial services works and how much you want to do it.
Thanks.
Martin
Bookmarks