use cell reference for named range

  • Thread starter Thread starter elf21
  • Start date Start date
E

elf21

I have named several ranges on my sheet with names of cities such a
"newYork", "Chicago", "sanDiego" etc.

I would like to use these ranges in a formula, but rather than type i
these ranges I would like to use a cell reference that contains thes
names.

For example, instead of typing =COUNT(Chicago) where "Chicago" is
range I have defined, I would like to be able to type something lik
=COUNT(A20) where A20 contains the text Chicago.

I hope I am making myself clear.
Thank you
 
=count(indirect(a20))
I have named several ranges on my sheet with names of cities such as
"newYork", "Chicago", "sanDiego" etc.

I would like to use these ranges in a formula, but rather than type in
these ranges I would like to use a cell reference that contains these
names.

For example, instead of typing =COUNT(Chicago) where "Chicago" is a
range I have defined, I would like to be able to type something like
=COUNT(A20) where A20 contains the text Chicago.

I hope I am making myself clear.
Thank you!
 
I just realized it doesn't work if the cell contains spaces such as in
"San Diego". I suppose it only reads the first word: San. How can I
get it to interpret the entire cell??

Thanks.
 
But you can't have a named range that includes a space.

If you name the range San_Diego (note the underscore), you could use:
=count(indirect(substitute(a20," ","_")))

If you name the range SanDiego (no spaces), you could use:
=count(indirect(substitute(a20," ","")))
 
I realized that shortly after I wrote it, that's why I deleted my post.
But I see you got to it before I had a chance to delete it!

Thank you for that other tip - using substitute. It allows for me to
retain the spaces within the contents of the cells - which simply looks
better on the spreadsheet.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Modify a range name with vb 2
Count of Font Format 1
Reference cells in named range 19
About references 1
COUNTIF + ADDRESS Issue 1
Chart with Named Range error 1
Excel VBA 1
Cell Value as Named Range Reference 1

Back
Top