View Single Post
  #4   Report Post  
Harlan Grove
 
Posts: n/a
Default

Curt D. wrote...
Thanks for the help Harlan, how would this be written in VBA if I want

the
first blank cell in column A to count all the no blank cells above it?

....

If you want the first blank cell in col A to become a cell with a
formula counting the preceding nonblank cells, you could try


Dim fnb As Range

Set fnb = Range("A1")

If IsEmpty(fnb.Value) Then
Set fnb = fnb.End(xlDown)

If fnb.Row = ActiveSheet.Rows.Count Then
MsgBox Prompt:="Column A is *ENTIRELY* blank. Nothing to count."
Set fnb = Nothing
End If

End If

If Not fnb Is Nothing Then
Set fnb = fnb.End(xlDown)

If fnb.Row < ActiveSheet.Rows.Count Then
fnb.Offset(1, 0).Formula = "=COUNTA(A1:" & fnb.Address(0, 0) & ")"

Else
MsgBox Prompt:="No blank cell below nonblank cells in which to
enter count."

End If

End If