Give this a try:
=COUNT(B8:INDEX(B8:AS8,MATCH(5,B8:AS8,0)))
Question
My excel sheet is as below
When I use the following formula the result is 8
=MATCH(5;B8:AS8;0)
I would like to expand this formula; not adding blank cells to range (B8:AS8
).
I mean if I don't add blank cells to range result will be 3
Which function must I use to expand my formula?
Solution
Give this a try:
=COUNT(B8:INDEX(B8:AS8,MATCH(5,B8:AS8,0)))
OTHER TIPS
Try this (basically, you're subtracting the blank cells):
=MATCH(5,B8:AS8,0)-COUNTIF(B8:AS8,"")
The following uses MATCH to find the location of the sought-after element, and COUNTBLANK to remove all blanks between the start of the list and the location of the found element:
In your specific case, you would probably use
=MATCH(5,$B$8:$AS$8,0)-
COUNTBLANK(INDIRECT("R8C2:R8C"&MATCH(5,$B$8:$AS$8,0),FALSE))
If the sought-after does not exist in the list, #N/A is returned.