Named Range Issue

MikeDBMan

Well-known Member
Joined
Nov 10, 2010
Messages
610
I have VBA code that opens a file, deletes a sheet called "Parameters" and then does this:

Code:
    Sheets("Parameters").Select
    ActiveWindow.SelectedSheets.Delete
'Now delete all the named ranges because they will reference errors
    ActiveWorkbook.Names("Fee").Delete
    ActiveWorkbook.Names("BillingEmail").Delete
    ActiveWorkbook.Names("BillingEmail2").Delete
    ActiveWorkbook.Names("BillingPhone").Delete
    ActiveWorkbook.Names("BillingPhone2").Delete
 
'Then it goes to the "master" file and gets the new paramters sheet and
'moves it to the open file (above) that had the parameters sheet removed
 
    Windows("Projects.xlsm").Activate
    Sheets("Parameters").Select
    Sheets("Parameters").Copy Before:=Workbooks(ThisBook).Sheets(1)
'ThisBook is the variable for the first file above.

The problem is that when I am in the first workbook the named ranges are now referenced as [Projects.xlsm]Parameters!$b$38, etc. Previously they were just Parameters!$B$38, etc. Any suggestions on how to get them to "copy over" successfully. Note: the scope on them is needed to always be Workbook because these parameters are used in many places throughout each workbook they appear in.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Maybe instead of deleting the sheet, you could copy the contents of the new sheet into it, preserving the names.
 
Upvote 0
That is certainly possible. But what is weird is that when using Excel 2010 it worked fine but now I have Excel 2007 and I have this issue. I will wait until tomorrow to see if someone has a better idea and then use your idea, which will certainly work just fine. Thanks for suggesting it. Sometimes I can't see the forest for the trees.
 
Upvote 0
That would be very nice behavior if it works as you say in 2010, caching the invalid names and fixing them when a worksheet reappears.
 
Upvote 0

Forum statistics

Threads
1,224,586
Messages
6,179,729
Members
452,939
Latest member
WCrawford

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