Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Referencing a named range based upon Range name entry in cell | Excel Worksheet Functions | |||
Array as a "named range" - formula ok in cells, but error as "named range" | Excel Discussion (Misc queries) | |||
inserting a named range into new cells based on a named cell | Excel Discussion (Misc queries) | |||
Compare a selected Range with a Named range and select cells that do not exist | Excel Programming | |||
If any cell in named range = 8 then shade named range | Excel Programming |