Import data into updated template - vba issues with duplicate named ranges

PatKlaus

New Member
Joined
Jan 3, 2014
Messages
5
I've got a very large template workbook with quite a few worksheets which is used for preparing labor and expense estimates for projects and then for tracking actual labor costs and expenses against the estimate. I now have a new version of the spreadsheet and we want to migrate all the older version spreadsheets into the new template. I'm trying to write a macro that will do this quickly. The problem I've encountered are the duplicate named ranges in the two spreadsheets.

Copying the data isn't the problem. I use statements like the following to handle that:

Workbooks(estFileName).Sheets("Worksheet Estimate").Range(codeNameCell).Value = Workbooks(pwFileName).Sheets("Worksheet Estimate").Range(codeNameCell).Value

Where I have an issue is trying to use a the preexisting subroutines to add rows/columns to the new file based on the named ranges to make enough room for the data to be copied. I had hoped that the Range method would default to the active workbook, but that apparently isn't happening.

Is there an easy way (without having to go back and edit about 5,600 lines of code) to make the commands in the existing subroutines use the active workbook? I have tried the Windows(estFileName).Activate command to make the new file (estFileName) the active file, but that doesn't seem to be working.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"

Forum statistics

Threads
1,216,371
Messages
6,130,217
Members
449,567
Latest member
ashsweety

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top