I have a spreadsheet that has a number of sections with a random number of rows for each one.
How can you find the last row for one of the section?
Example:
-------------------------------------------------------
ROW 1
-------------------------------------------------------
ROW 2
-------------------------------------------------------
ROW 3
-------------------------------------------------------
ROW 4
-------------------------------------------------------
LAST ROW <-- Select last row
However this can different for each section where the number of rows is different:
-------------------------------------------------------
ROW 1
-------------------------------------------------------
ROW 2
-------------------------------------------------------
LAST ROW <-- Select last row
This is the code I have already:
Sub AddNewAllocToSpendLine(sectionHeading As String, Optional sSheetName As String = c_Alloc2SpendSheetName)
Worksheets(sSheetName).Activate
'get the section heading position
Set c = Worksheets(sSheetName).Range("A:A").Find(sectionHeading, LookIn:=xlValues, LookAt:=xlWhole)
Debug.Print c
Dim addrow As String
Dim lRow As Long
addrow = c.Row + 1
If addrow <> "" And IsNumeric(addrow) = True Then
Rows(addrow).Insert shift:=xlDown
Else
MsgBox ("enter only row number")
End If
End Sub