Count blanks prior to final cell with value

jjrrcc11

Board Regular
Joined
Apr 11, 2016
Messages
53
Hello

I need to count the number of blank cells, but wish to only count the blanks prior to the final column with a value in, even if there are blanks after this column.

So for example:

Row 2's last value is in column BD, so I wish to count the number of blanks between A and BD... despite there being further blanks after BD... I do not wish for these to be included.
Row 3's last value is in BN... so similarly I only wish for the blanks prior to BN to be counted.

This is a 7000+ row spreadsheet and each row may have a different last value point... The value is always a date. I'd ideally like the sum of blanks for each row to be displayed at the end of each row, say in column DE.

Ideally a formula would be best if it can be accomplished with one, rather than VB.

Thanks in advance
 
Last edited:

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest
Insert in DE1 and drag down(Confirm with CTRL-SHIFT-ENTER):

=COUNTBLANK(INDIRECT("A1:"&ADDRESS(ROW(A1),LARGE(IF(A1:DD1<>"",COLUMN(A1:DD1)),1))))
 
Upvote 0
my only way would be through VBA

Code:
Function totalblanks(r As Long)
Dim lc1 As Long, lc2 As Long
lc1 = Cells(r, Columns.Count).End(xlToLeft).Column - 1
Do While Cells(r, lc1).Value = ""
lc1 = lc1 - 1
Loop
totalblanks = WorksheetFunction.CountBlank(Range(Cells(r, 1), Cells(r, lc1)))
End Function

enter into cell as below

=totalblanks(ROW())
 
Upvote 0

Forum statistics

Threads
1,214,647
Messages
6,120,722
Members
448,987
Latest member
marion_davis

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