mattygriff
Programmer
I have an Excel workbook which, when opened, generates a new payment number. A macro then checks the Payment List sheet to see if the list is full. If it is, a new line is inserted below the last entry.
I'd be grateful for any help you might have.
Code:
Option Explicit
Dim numPayments As Long
Dim numPaymentsMaxLength As Long
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then
numPayments = Sheet2.Range("PAYMENTS_LIST").Rows.Count
numPaymentsMaxLength = Sheet2.Range("MAX_PAYMENT_LIST").Rows.Count
If numPayments >= numPaymentsMaxLength Then
Sheet2.Unprotect
Rows(11 + numPayments).Insert Shift:=xlDown
Sheet2.Protect
End If
End If
End Sub
I'd be grateful for any help you might have.