Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 118
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 336
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Referencing a named range based upon Range name entry in cell Barb Reinhardt Excel Worksheet Functions 14 June 20th 07 07:19 PM
Array as a "named range" - formula ok in cells, but error as "named range" tskogstrom Excel Discussion (Misc queries) 11 December 28th 06 04:44 PM
inserting a named range into new cells based on a named cell Peter S. Excel Discussion (Misc queries) 1 June 4th 06 03:53 AM
Compare a selected Range with a Named range and select cells that do not exist PCLIVE Excel Programming 1 October 18th 05 07:09 PM
If any cell in named range = 8 then shade named range JJ[_8_] Excel Programming 3 August 26th 05 11:09 PM


All times are GMT +1. The time now is 03:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"