Can anyone help me with this macro to create multiple sub totals in one column? Any help would be great. I have a group of numbers in column Y. which begins at row 16. The data is listed on every three lines until the end of that section then there is a gap of around thirty lines then it beings again. I want to create a macro to count how many numbers >45 in each section. Put the total 2 rows below the last data point of each section. In column X on the same row place Number>45
Sub Sample()
    Dim result As Long, firstrow As Long, lastrow As Long
    Dim ws As Worksheet
    Dim rng As Range
    Set ws = ThisWorkbook.Sheets("Sheet1")
    With ws
        '~~> Find Lastrow in Col Y
        lastrow = .Range("Y" & .Rows.Count).End(xlUp).Row
        '~~> Set First row
        firstrow = 16
        '~~> Set your range
        Set rng = .Range("Y" & firstrow & ":Y" & lastrow)
        '~~> Put relevant values
        .Range("x" & lastrow + 2).Value = "Total>45"
        .Range("y" & lastrow + 2).Value = _
        Application.WorksheetFunction.CountIf(rng, ">45")
    End With
End Sub
 
     
    
