Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 262
Default Problem with named ranges

I have two named ranges. The first is a list of hospitals and is in Column
A, it is used as a validation list for a column on another sheet.

The second is Column A again along with Column B (which contains the City
the hospital is in). It is used so that when the user selects the correct
hospital the City is automatically input using the vlookup function.

This works great.

I also have a button on the worksheet with the named ranges that sorts the
lists alphabetically.

The Idea is that the user can add a new hospital to the bottom of the list
then click the button to re-sort the list. Again this works fine.

The user can also remove an entry from the list and tell Excel to move the
cells up so there are no gaps in the list. This is where I start having
problems.

If the entry is removed from somewhere in the middle of the list for example
then everything is fine, but if the entry to be removed is the very first row
of the named range then I get a #Ref error in the ranges definition.

The definition I use for the A and B range is:

=OFFSET(Lists!$A$2,0,0,COUNTA(Lists!$A:$A)-1,2)

How can I get around this problem?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 923
Default Problem with named ranges

One possible approach, add a header row and make that the first row of the
range, protect the cells and the user cannot remove?

..

--
Cheers
Nigel



"Keith" wrote in message
...
I have two named ranges. The first is a list of hospitals and is in Column
A, it is used as a validation list for a column on another sheet.

The second is Column A again along with Column B (which contains the City
the hospital is in). It is used so that when the user selects the correct
hospital the City is automatically input using the vlookup function.

This works great.

I also have a button on the worksheet with the named ranges that sorts the
lists alphabetically.

The Idea is that the user can add a new hospital to the bottom of the list
then click the button to re-sort the list. Again this works fine.

The user can also remove an entry from the list and tell Excel to move the
cells up so there are no gaps in the list. This is where I start having
problems.

If the entry is removed from somewhere in the middle of the list for
example
then everything is fine, but if the entry to be removed is the very first
row
of the named range then I get a #Ref error in the ranges definition.

The definition I use for the A and B range is:

=OFFSET(Lists!$A$2,0,0,COUNTA(Lists!$A:$A)-1,2)

How can I get around this problem?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Problem with named ranges

but if the entry to be removed is the very first row
of the named range then I get a #Ref error in the ranges definition.


By 'very first row' I assume you mean to A2, first row below the header in
A1

Your offset is relative to A2 so if you 'move' another cell to A2, the A2 in
the original formula no longer exists. To demonstrate try this -

=$A$2
now drag a cell to A2, I expect the formula will now return #REF!

Try amending your Offset -
=OFFSET(Lists!$A$1,1,0,COUNTA(Lists!$A:$A),2)

Regards,
Peter T

"Keith" wrote in message
...
I have two named ranges. The first is a list of hospitals and is in

Column
A, it is used as a validation list for a column on another sheet.

The second is Column A again along with Column B (which contains the City
the hospital is in). It is used so that when the user selects the correct
hospital the City is automatically input using the vlookup function.

This works great.

I also have a button on the worksheet with the named ranges that sorts the
lists alphabetically.

The Idea is that the user can add a new hospital to the bottom of the list
then click the button to re-sort the list. Again this works fine.

The user can also remove an entry from the list and tell Excel to move the
cells up so there are no gaps in the list. This is where I start having
problems.

If the entry is removed from somewhere in the middle of the list for

example
then everything is fine, but if the entry to be removed is the very first

row
of the named range then I get a #Ref error in the ranges definition.

The definition I use for the A and B range is:

=OFFSET(Lists!$A$2,0,0,COUNTA(Lists!$A:$A)-1,2)

How can I get around this problem?



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Problem with named ranges

Forgot to reduce count & row height by 1 to exclude the header row

=OFFSET(Lists!$A$1,1,0,COUNTA(Lists!$A:$A)-1,2)

Peter T

"Peter T" <peter_t@discussions wrote in message
...
but if the entry to be removed is the very first row
of the named range then I get a #Ref error in the ranges definition.


By 'very first row' I assume you mean to A2, first row below the header in
A1

Your offset is relative to A2 so if you 'move' another cell to A2, the A2

in
the original formula no longer exists. To demonstrate try this -

=$A$2
now drag a cell to A2, I expect the formula will now return #REF!

Try amending your Offset -
=OFFSET(Lists!$A$1,1,0,COUNTA(Lists!$A:$A),2)

Regards,
Peter T

"Keith" wrote in message
...
I have two named ranges. The first is a list of hospitals and is in

Column
A, it is used as a validation list for a column on another sheet.

The second is Column A again along with Column B (which contains the

City
the hospital is in). It is used so that when the user selects the

correct
hospital the City is automatically input using the vlookup function.

This works great.

I also have a button on the worksheet with the named ranges that sorts

the
lists alphabetically.

The Idea is that the user can add a new hospital to the bottom of the

list
then click the button to re-sort the list. Again this works fine.

The user can also remove an entry from the list and tell Excel to move

the
cells up so there are no gaps in the list. This is where I start having
problems.

If the entry is removed from somewhere in the middle of the list for

example
then everything is fine, but if the entry to be removed is the very

first
row
of the named range then I get a #Ref error in the ranges definition.

The definition I use for the A and B range is:

=OFFSET(Lists!$A$2,0,0,COUNTA(Lists!$A:$A)-1,2)

How can I get around this problem?





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 262
Default Problem with named ranges

Peter,

Your solution worked perfectly.

Thanks very much. I was really stuck on this one.

Keith

"Peter T" wrote:

Forgot to reduce count & row height by 1 to exclude the header row

=OFFSET(Lists!$A$1,1,0,COUNTA(Lists!$A:$A)-1,2)

Peter T

"Peter T" <peter_t@discussions wrote in message
...
but if the entry to be removed is the very first row
of the named range then I get a #Ref error in the ranges definition.


By 'very first row' I assume you mean to A2, first row below the header in
A1

Your offset is relative to A2 so if you 'move' another cell to A2, the A2

in
the original formula no longer exists. To demonstrate try this -

=$A$2
now drag a cell to A2, I expect the formula will now return #REF!

Try amending your Offset -
=OFFSET(Lists!$A$1,1,0,COUNTA(Lists!$A:$A),2)

Regards,
Peter T

"Keith" wrote in message
...
I have two named ranges. The first is a list of hospitals and is in

Column
A, it is used as a validation list for a column on another sheet.

The second is Column A again along with Column B (which contains the

City
the hospital is in). It is used so that when the user selects the

correct
hospital the City is automatically input using the vlookup function.

This works great.

I also have a button on the worksheet with the named ranges that sorts

the
lists alphabetically.

The Idea is that the user can add a new hospital to the bottom of the

list
then click the button to re-sort the list. Again this works fine.

The user can also remove an entry from the list and tell Excel to move

the
cells up so there are no gaps in the list. This is where I start having
problems.

If the entry is removed from somewhere in the middle of the list for

example
then everything is fine, but if the entry to be removed is the very

first
row
of the named range then I get a #Ref error in the ranges definition.

The definition I use for the A and B range is:

=OFFSET(Lists!$A$2,0,0,COUNTA(Lists!$A:$A)-1,2)

How can I get around this problem?






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
Problem creating named ranges in a Macro! LABKHAND Excel Discussion (Misc queries) 2 January 8th 10 04:58 PM
problem in deleting the named ranges Maya[_2_] Excel Worksheet Functions 1 June 28th 07 12:52 PM
Copy data in named ranges to a newer version of the same template to identical ranges handstand Excel Programming 0 August 21st 06 03:51 PM
Problem with Dynamic Named Ranges Andibevan Excel Worksheet Functions 4 October 5th 05 12:56 PM
Problem Working with Named Ranges montgomerymouse Excel Discussion (Misc queries) 1 January 10th 05 10:45 PM


All times are GMT +1. The time now is 11:43 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"