Count the number of blank cells until next filled cell is found

Bookender

New Member
Joined
Sep 18, 2013
Messages
47
Okay, so. I have a sheet with data in all sorts of random cells. However, I only need the information from a few specific ones, so, when I import those columns, I get data that's all over the place.

1
Fish
2
Spoon
3
4
Drink
5
6
Tree
7
Shoe
Four
8
Eight
9
10
Night

<TBODY>
</TBODY>



I would like to get this data 'gathered' so that it takes up as little space as possible, while still keeping the different rows apart. And I want to do this with an INDEX command (no arrays, no VBA). I want to do this by having a helper column that does a simple check, and adds one to the number above itself if any of the cells in a row isn't blank; otherwise (and this is where I have trouble), I want it to add the number of blank cells until next non-blank is encountered. So the row with Fish would be 1, the row with Shoe would be 2, and then the row after that would say 4, as it counts the blank cell before Drink - and then the sequence would continue with 6, 7, 8, 10. In order. As demonstrated:
1
2
4
6
7
8
10

<TBODY>
</TBODY>


Anyone got any ideas for how to do that counting? (my apologies if this exact question has already been answered, but an intial search did not yield anything I could use)
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
helpercol1helpercol2
1Fish11
2Spoon12
30
4Drink13
50
6Tree14
7ShoeFour15
8Eight16
90
10Night17
1Fish00
20Spoon0
30Drink0
4Tree00
5Shoe0Four
600Eight
70Night0
would this approach be acceptable

<colgroup><col width="64" span="6" style="width:48pt"> </colgroup><tbody>
</tbody>
 
Upvote 0
That would work just fine, oldbrewer. Though I admit that I am a bit at a loss as to how to get it to end up the way you demonstrate.
 
Last edited:
Upvote 0
the first helper column puts a 1 if there is anything in the row, the second helper column adds up the 1's sequentially.
The new table uses offset / match function - will post the formulas shortly.
 
Upvote 0
helpercol1helpercol2
1Fish11
2Spoon12
300
4Drink13
500
6Tree14
7ShoeFour15
8Eight16
900
10Night17
########
1Fish
2Spoon
3Drink
4Tree
5ShoeFour
6Eight
7Night
first cell under helpercol2 heading (which is E2)
=IF(AND(B2="",C2="",D2=""),0,1)
cell to the right of that (which is F2)
=IF(E2=0,"",1)
cell below that (which is F3)
=IF(E3=0,0,1+MAX($F$2:F2))
cell below ######## (which is B14)
=IF(OFFSET($F$1,MATCH($A14,$F$2:$F$11,0),-4)=0,"",OFFSET($F$1,MATCH($A14,$F$2:$F$11,0),-4))
this is copied across then change the two -4's to -3 and -2
then copy down

<colgroup><col span="10"></colgroup><tbody>
</tbody>
 
Upvote 0
Hm. Well, following the instructions you gave precisely did.. not work. At all. My guess is there is a typo somewhere. But, I'm afraid that I am sufficiently unfamiliar with OFFSET to understand its function - could you be kind and provide an explanation of how your code works?
 
Upvote 0
I copied and pasted the formulas from my test spreadsheet, so check your end for typos please.
Offset works by starting at a reference cell, in this case F1, then it goes down the required number of cells, then along the required number of cells.
So =offset(F1, 5,2) would return the value of cell H6.
=offset(F1, 5,-3) would return the value of cell C6

the match function is used here to define how many cells down, looking first for a 1 in column F before going 4 cells to the left to find FISH
 
Upvote 0
Really strange; I've copy-pasted from the thread, so that rules out any typos I could have done. The core data is in B2:D11, correct? With first helper column starting in E2, the second in F2, and then the Offsets going in B14:D25. If that is correct, then the formulas have been inserted as per your instructions...

But, B14:D25 remain blank (and yes, I did make sure that the sheet calculated the formula) - which is what puzzles me. Perhaps it is the fact that you reference $A14 and down, which is a blank column?
 
Upvote 0

Forum statistics

Threads
1,214,652
Messages
6,120,747
Members
448,989
Latest member
mariah3

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