If I'm getting the result $F$1:$F$21 from using .Address on a Range, is there a way to seperate just the F21 part and then use .Offset to tell excel the cell I want to put a value in?
Public Sub TotalAudits()
With Worksheets(1)
'Dim lastrow As Long: Set lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
Dim celTotal As Range: Set celTotal = .Cells(.Rows.Count, "A").End(xlUp).Row.Offset(2, 4)
celTotal.Value = "Monthly Totals"
With celTotal
.Font.Bold = True
.Font.Italic = True
.HorizontalAlignment = xlRight
End With
Dim rngMonth As Range
For Each rngMonth In Range("F1:Q" & .Cells(.Rows.Count, 1).End(xlUp).Row).Columns
Dim colTotal As Integer: colTotal = rngMonth.Cells.SpecialCells(xlCellTypeConstants).Count - 1
.Range(Split(rngMonth.Address(False, False), ":")(1)).Offset(2, 0).Value = colTotal
'MsgBox (rngMonth.Address)
Next rngMonth
'MsgBox (lastrow)
End With
End Sub
Specifically, this area of code....
MsgBox (rngMonth.Address)
I want to offset the last part of the address by 2 rows and insert the value stored in colTotal in that offset cell.