Afternoon all,
I had this code that when I initially placed it in, stopped the entire row from being deleted if it was A4 and it worked fine.
For whatever reason (gremlins) it is no longer working and know matter what, the message box always appears. Does anyone know why? I've tried modifying it to be A3, however when tested it deletes A4 and then seems to work...
I had this code that when I initially placed it in, stopped the entire row from being deleted if it was A4 and it worked fine.
For whatever reason (gremlins) it is no longer working and know matter what, the message box always appears. Does anyone know why? I've tried modifying it to be A3, however when tested it deletes A4 and then seems to work...
VBA Code:
Sub RemoveLastRow()
If Range("A" & Rows.Count).End(xlUp) = ActiveSheet.Range("A4") Then 'stops deletion
MsgBox "Cannot delete any further."
Exit Sub
End If
ActiveSheet.Cells(Rows.Count, "A").End(xlUp).EntireRow.Delete 'selects the last row of the sheet and deletes
End Sub