Theoretical Question

Domenic

MrExcel MVP
Joined
Mar 10, 2004
Messages
21,617
Office Version
  1. 365
Platform
  1. Windows
I'm trying to understand the following formula...

{=COUNT(TRANSPOSE(INDIRECT(ADDRESS(2+3*ROW(INDIRECT("1:75")),3))))}

If we take a look at the evaluation prior to COUNT, an array of #VALUE! errors is returned.

If we then de-reference using N(), we get an array of numerical values, including zero's.

Question 1
-----------

Why is the function TRANSPOSE needed in the formula?

Question 2
-----------

Why doesn't the result of the formula equal 75, since the array returned is made up of numerical values, including zero's (or is it)?

Any help would be greatly appreciated!
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
You're getting 32?

EDIT - Guessing that the formula's intent was to count in a single row across every 3rd column from E and transposing the row refs was easier than using some sort of INDEX/MOD arrangement?

Not that familiar w/ TRANSPOSE in formulas, I'm afraid.
 
Upvote 0
just_jon said:
You're getting 32?

Hi Jon!

No, actually, let's say I have 5 numerical values in 5 out of the 75 cells referenced by the formula. The formula returns 5, which is fine, but why doesn't it return 75 (the number of cells referenced by the formula) since the array returned prior to COUNT consists of numerical values for all 75 cells referenced, with zero's being returned for empty cells? Or is this not the case?
 
Upvote 0
Hiya Domenic - I think the array being returned is cell 5 , cell 8, cell 11 and so on. Originally in a column but transposed to a row; so if all cells had a value, you'd get 32.

EDIT - Nope, it's counting the column's values, but just 5-8-11-etc.

But, I could also be so far off as to make MrExcel weep!

BTW, good work here. (y)
 
Upvote 0
just_jon said:
Guessing that the formula's intent was to count in a single row across every 3rd column from E and transposing the row refs was easier than using some sort of INDEX/MOD arrangement?

Actually, the formula's intent is to count in a single column, ranging from C5 to C227. That's why I don't understand why TRANSPOSE is needed in the first place.

Personally, I would probably use some variation of the MOD function, but I'd really like to understand how and why this formula works. :)

P.S. Just noticed your post.
 
Upvote 0
Wondering if, like VBA, transposed is used here to generate a single dimension array in lieu of an N x 1 array?
 
Upvote 0
Array's going down differing rows will need to be a semi-colon seperated value array, whereas a singular row array can be a comma seperated array.
 
Upvote 0
Thanks, Zack - so we're getting $C$5;$C$8;$C$11 on thru C227 and then getting a comma-for-semicolon swap via TRANSPOSE in order to feed COUNT its expected comma-seperated range list... that's pretty neat.
 
Upvote 0
just_jon said:
...and then getting a comma-for-semicolon swap via TRANSPOSE in order to feed COUNT its expected comma-seperated range list...

It shouldn't matter whether the range list is separated by a comma or semi-colon, should it? I just tried...

=COUNT({2;3;5;"";8;0})

...and got a correct result of 5.
 
Upvote 0
I believe TRANSPOSE() has two effects: (a) To ensure that the reference for COUNT is vertical and (b) to effect the 'required' dereferencing. Without the latter, COUNT() would count the numbers returned by ROW(), not the values the row numbers would refer.

Note that F9 returns 0's for empty cells, however, those 0's are not visible to COUNT(). This can be verified...

A1: 3
A2: empty
A3: 8

=COUNT(A1:A3) ==> 2

Apply F9 on just the A1:A3 bit. What you see would be:

{3,0,8}

while COUNT() will be handed:

{3;"";8}

Hence, 2 as result.
 
Upvote 0

Forum statistics

Threads
1,215,831
Messages
6,127,144
Members
449,363
Latest member
Yap999

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top