Mar 02 2020 09:39 AM
Hello guys.
I need some help in order to create a macro which enable user to delete the entire row 4 after entering data in cell A9 in a control spreadsheet
My goal is to keep the last five records only in the spreadsheet.
Thanks a lot!
Mar 03 2020 12:13 AM
@macedosf Inspired by the information in this link:
https://docs.microsoft.com/en-us/office/troubleshoot/excel/run-macro-cells-change
You could adapt the code like this:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim KeyCell As Range
Set KeyCell = Range("A9")
If Not Application.Intersect(KeyCell, Range(Target.Address)) _
Is Nothing Then
Rows("4:4").Select
Selection.Delete Shift:=xlUp
End If
End Sub
....and place it in the in the code section for the worksheet (i.e. not in a separate module).
Mar 03 2020 07:37 AM
I added a macro (macro1) which automatically delete the entire row 4 which is also clickable once they click it. I also made the link non-printable so it doesn't mess up your report if you print it.
Mar 04 2020 02:49 PM
Mar 04 2020 02:51 PM