MrSourApple
New Member
- Joined
- Oct 23, 2015
- Messages
- 17
I need to create multiple named ranges for a workbook that is updated regularly. Each time the workbook is updated a new worksheet is added and it needs named ranges to make other formulas in the workbook continue to work.
So to try and summarize: I want to create named ranges on the new tab, the new tab name is referenced in Admin!E1. The names for the named ranges are listed in 'Named Ranges'!B2:B29.
Here is what I put together, please help (this is just for the first named range not for all):
Sub MakeNamedRanges()
Set UIIRng = Sheets(Sheets("Admin").Range("E1").Value).Range("B:B")
- "Admin" tab: This tab has the name of the new worksheet that will be created in cell E1 (since it changes regularly the creation of the worksheet is macro driven)
- "Named Ranges" tab: This tab has the names that need to be used for the named ranges in cells B2:B29 (B2 is a named range for column B of the new tab, B3 another named range for column C of the new tab...)
So to try and summarize: I want to create named ranges on the new tab, the new tab name is referenced in Admin!E1. The names for the named ranges are listed in 'Named Ranges'!B2:B29.
Here is what I put together, please help (this is just for the first named range not for all):
Sub MakeNamedRanges()
Set UIIRng = Sheets(Sheets("Admin").Range("E1").Value).Range("B:B")
ActiveWorkbook.Names.Add _
Name:=Sheets(Sheets("Named Ranges").Range("B2").Value), RefersTo:=UIIRng
End Sub