Eric Penfold
Active Member
- Joined
- Nov 19, 2021
- Messages
- 431
- Office Version
- 365
- Platform
- Windows
- Mobile
Please help to make the function count the oldrows
VBA Code:
Public Sub Delete_Or_Insert_Rows()
Dim NewRowCount As Long
Dim OldRowCount As Long
Dim LRow As Long
Dim rng As Range
Dim ws As Worksheet
Set ws = ActiveSheet
LRow = Range("A1").End(xlDown).Row
Set rng = ws.Range("A1:A" & LRow)
OldRowCount = OldrowQty
NewRowCount = rng.Rows.Count
If OldRowCount > NewRowCount Then
Exit Sub
OldRowCount = NewRowCount
ElseIf OldRowCount < NewRowCount Then
Exit Sub
ElseIf OldRowCount = NewRowCount Then
Call Group_OrderNos
End If
End If
End Sub
Public Function OldrowQty(rng As Range) As String
Dim OldRowCount As Long
Dim LRow As Long
Dim ws As Worksheet
Set ws = ActiveSheet
LRow = Range("A1").End(xlDown).Row
Set rng = ws.Range("A1:A" & LRow)
OldrowQty = rng.Rows.Count
End Function