The below macro runs through by searching the sub-ledger header and sum the values below the header. If there is no value below the third search under Sub-Ledger header, how we need to skip and go ahead with processing the macro.
I have added the snapshot where the third column Sub-Ledger Header has no values below and we couldn't able to total the single blank cell using the code below.
Sub FACP_REPORTS()
Dim sFirst As Range, st1 As Range
Dim sSecond As Range, st2 As Range
Dim A As Range
Dim B As Range
Dim Sumtotal As Variant
Application.DisplayAlerts = False
Sheets("FA_CP_Report").Select
Range("A1").Select
Set A = Range("F:G")
Set B = Range("G:H")
Do
If sFirst Is Nothing Then
Set sFirst = A.Find(What:="Sub-ledger")
Set st1 = sFirst
Else
Set st1 = A.Find(What:="Sub-ledger", After:=st1)
If st1.Address = sFirst.Address Then Exit Do
End If
st1.Select
Selection.End(xlDown).Select
Range(ActiveCell, ActiveCell.End(xlDown)).Select
Sumtotal = Application.WorksheetFunction.Sum(Selection)
Selection.End(xlDown).Offset(2, 0).Select
ActiveCell.Value = Sumtotal
Selection.NumberFormat = "0.00"
Selection.Style = "Comma"
ActiveCell.Font.Bold = True
ActiveCell.Interior.ColorIndex = 27
ActiveCell.Borders.LineStyle = xlContinuous
Loop
Application.DisplayAlerts = True
End Sub