Formula to refer to a column as number (Not VBA)

gilsa

New Member
Joined
Sep 16, 2014
Messages
21
Hi All,
I'd like to use the countif formula to count non blank cells in dynamic column.
I use MATCH to find the column number I need to find the cells in, however how do I refer to a column using its number?

i.e let's say my match function returns 2 (meaning column B), so I'd like to use: countif(B3:INDEX(B:B,$C$1),"<>"&"").
if it returns 4 then it will be D4 and D:D respectively.

Any idea/help would be highly appreciated!
 
Hi.

Do you really need to restrict the number of rows being passed? COUNTIF(S)/SUMIF(S) are exceptional among Excel functions in that they suffer no detriment to performance if you pass entire columns.

So, you could use:

=COUNTIF(INDEX($A:$XFD,,match_result),"<>")

where obviously you replace match_result appropriately.

Regards
 
Last edited:
Upvote 0
Thanks for your prompt response!
3:3 refers to entire row 3, however I need to refer to Column 3 (C).
Also how do I pass my match result into the countif function?
 
Upvote 0
If C1 contains 4 then

=INDEX(3:3,$C$1)

will return the value in D3, or a reference to that cell. So:

=SUM(B3:INDEX(3:3,$C$1))

will return the sum of B3:D3.
 
Upvote 0

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