Insert formula for next completely blank row

LNG2013

Active Member
Joined
May 23, 2011
Messages
466
I am trying to inset a count formula in column F of the next completely blank row of a sheet to count from 1 above its location to the top of the page -2 the two very top lines (header and a blank line).
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
So if I were using this in a regulare sheet I would say
Range("L4").Formula = "=COUNT(F:F)"

But I need the formula Range to be the last completely blank row of column F, the Count then needs to be adjust for this as well saying to Count from starting at the row above its position to the top, 2 lines for the header and another blank line.
 
Upvote 0
Try:

Code:
Sub Test()
    Dim LastRow As Long
    With Worksheets("Sheet1")
        LastRow = .Range("F" & .Rows.Count).End(xlUp).Row
        .Range("F" & LastRow + 1).Formula = "=COUNT(F3:F" & LastRow & ")"
    End With
End Sub

Change the worksheet reference to suit.
 
Upvote 0
Thanks Andrew that worked very well!

Is there a way to amend this same code so that it then does a count for columns G, H, I, & J, but puts the count formula each to the right of the found F field (this way they are all in the same row)?

I have attached a Workbook for reference. I replicated your code 5x, adjusting for the different columns, but it places the value to the last row of that specific column instead of the same row as the column F count.

http://dl.dropbox.com/u/550012/EndSummary.xls
 
Upvote 0
Just expand the range:

Code:
Sub Test()
    Dim LastRow As Long
    With Worksheets("Sheet1")
        LastRow = .Range("F" & .Rows.Count).End(xlUp).Row
        .Range("F" & LastRow + 1 & ":J" & LastRow + 1).Formula = "=COUNT(F3:F" & LastRow & ")"
    End With
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,071
Messages
6,182,687
Members
453,132
Latest member
nsnodgrass73

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