COUNTA formula with indirect reference - help please!

J

Jason Lang

Hi--

I am getting strange results with a formula. I would like to use
COUNTA to count non blanks in a worksheet called "Data". I'd like it
to take column values from cells C2 and D2 to get the range of data in
"Data" to count. What I have is:

=COUNTA("Data!"&$C$2&ROW()&":Data!"&$D$2&ROW())

However, this always returns 1 regardless of the number of blanks.

I think my problem is related to the following. Just playing around,
I tried a direct formula to count nonblanks in columns AE:AJ:

=COUNTA(Data!AE3:Data!AJ3) --- Works correctly
=COUNTA("Data!AE3:Data!AJ3") --- always returns 1 like my example
above

Any suggestions for how to get the first formula to work correctly?

Thanks!
 
D

Dave Peterson

Maybe...
=COUNTA(INDIRECT("Data!"&$C$2&ROW()&":"&$D$2&ROW()))

Your formula which boils down to this:
=COUNTA("Data!AE3:Data!AJ3")

Is counting how many things are inside those (). In this case you have a single
string, so you get 1.

=counta("a","b")
would return 2

=COUNTA(Data!AE3:Data!AJ3)
More often written like:
=COUNTA(Data!AE3:AJ3)
will count the non-empty cells in AE3:AJ3 of the Data worksheet.
 
P

Pete_UK

You can build up a cell or range address as a string (as you are
trying to do), but you must use the INDIRECT function to get Excel to
recognise it. Try this:

=COUNTA(INDIRECT("Data!"&$C$2&ROW()&":Data!"&$D$2&ROW()))

Hope this helps.

Pete
 
J

Jason Lang

Hi all--
Thanks so much for the replies. Unfortunately, all of these formulas
continue to give me the value of "1" when I put them in my
spreadsheet. Any other ideas?

Jason
 
T

T. Valko

Getting all of those "stupid" quotes in the correct order can be a challenge
sometimes! That's what usually trips people up.

Thanks for feeding back!
 

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

Top