![]() |
Named Range?
Hello,
I have this code on the followhyperlink: If ActiveCell.Address = "$B$6" Then Rows("11:110").EntireRow.Hidden = False The rows 11 to 110 may change so I want to use named ranges but when I name this range the code doesnt work. Is there a different way to reference the named range? Thanks in advance. Martin |
Named Range?
How about:
Sub dural() If ActiveCell.Address = "$B$6" Then Range("myrange").EntireRow.Hidden = False End Sub where myrange is defined on the worksheet with: Insert Name -- Gary''s Student - gsnu200834 "Martin" wrote: Hello, I have this code on the followhyperlink: If ActiveCell.Address = "$B$6" Then Rows("11:110").EntireRow.Hidden = False The rows 11 to 110 may change so I want to use named ranges but when I name this range the code doesnt work. Is there a different way to reference the named range? Thanks in advance. Martin |
Named Range?
If Range("Martin").Address = "$B$6" Then Rows("11:110").EntireRow.Hidden =
False "Martin" wrote: Hello, I have this code on the followhyperlink: If ActiveCell.Address = "$B$6" Then Rows("11:110").EntireRow.Hidden = False The rows 11 to 110 may change so I want to use named ranges but when I name this range the code doesnt work. Is there a different way to reference the named range? Thanks in advance. Martin |
Named Range?
Thanks, worked perfectly. I hadnt defined the range using the insert | name
method Martin "Gary''s Student" wrote: How about: Sub dural() If ActiveCell.Address = "$B$6" Then Range("myrange").EntireRow.Hidden = False End Sub where myrange is defined on the worksheet with: Insert Name -- Gary''s Student - gsnu200834 "Martin" wrote: Hello, I have this code on the followhyperlink: If ActiveCell.Address = "$B$6" Then Rows("11:110").EntireRow.Hidden = False The rows 11 to 110 may change so I want to use named ranges but when I name this range the code doesnt work. Is there a different way to reference the named range? Thanks in advance. Martin |
Named Range?
Hi Martin
VB refers to ALL names defined in a worksheet as an object (Name object). To use your specific name you need to call it by indexing in one of two ways. 1) Names are organised alphabetically and then indexed numerically i.e. if you had "Apples", "Bananas" and "Oranges", then Apples is indexed as 1, Bananas as 2 etc. If you wanteed to use apples in the VB code you would call it as follows: MyRange = Names (1). I don't like this because if you add a name that comes before this one alphabetically, I can't tell whether excel automatically reindexes so that the code still refers to the right range. 2) Use the names object to call you range by its name: MyRange = Names("Apples") Hope this helps. "Martin" wrote: Hello, I have this code on the followhyperlink: If ActiveCell.Address = "$B$6" Then Rows("11:110").EntireRow.Hidden = False The rows 11 to 110 may change so I want to use named ranges but when I name this range the code doesnt work. Is there a different way to reference the named range? Thanks in advance. Martin |
Named Range?
That is very helpful and thank you for your time.
Martin "BSc Chem Eng Rick" wrote: Hi Martin VB refers to ALL names defined in a worksheet as an object (Name object). To use your specific name you need to call it by indexing in one of two ways. 1) Names are organised alphabetically and then indexed numerically i.e. if you had "Apples", "Bananas" and "Oranges", then Apples is indexed as 1, Bananas as 2 etc. If you wanteed to use apples in the VB code you would call it as follows: MyRange = Names (1). I don't like this because if you add a name that comes before this one alphabetically, I can't tell whether excel automatically reindexes so that the code still refers to the right range. 2) Use the names object to call you range by its name: MyRange = Names("Apples") Hope this helps. "Martin" wrote: Hello, I have this code on the followhyperlink: If ActiveCell.Address = "$B$6" Then Rows("11:110").EntireRow.Hidden = False The rows 11 to 110 may change so I want to use named ranges but when I name this range the code doesnt work. Is there a different way to reference the named range? Thanks in advance. Martin |
All times are GMT +1. The time now is 03:03 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com