This macro I have doesn't work because it will deletes two rows directly below the row I'm in that have data in them.
This causes problems because those rows below me may already have data in them.
I need to change the .EntireRow.Delete line below to instead delete the next two blank rows that are beneath the last filled row in the worksheet. I'm just getting started in using VBA and have tried multiple different codes but cannot figure it out. Please help!
This causes problems because those rows below me may already have data in them.
I need to change the .EntireRow.Delete line below to instead delete the next two blank rows that are beneath the last filled row in the worksheet. I'm just getting started in using VBA and have tried multiple different codes but cannot figure it out. Please help!
Code:
[SIZE=3][COLOR=#000000][FONT=Calibri]Private Sub Worksheet_Change(ByVal Target As Range)<o:p></o:p>[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Calibri]If Target.Count > 1 Then Exit Sub<o:p></o:p>[/FONT][/COLOR][/SIZE]
<o:p>[FONT=Calibri][SIZE=3][COLOR=#000000] [/COLOR][/SIZE][/FONT]</o:p>
[SIZE=3][COLOR=#000000][FONT=Calibri]Dim RowNum As Long<o:p></o:p>[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Calibri] RowNum = Target.Row<o:p></o:p>[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Calibri] <o:p></o:p>[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Calibri] If WorksheetFunction.CountA(Range("D" & RowNum & ":S" & RowNum)) > 1 Then<o:p></o:p>[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Calibri] Range("D" & RowNum & ":S" & RowNum).ClearContents<o:p></o:p>[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Calibri] Range("D" & RowNum).Select<o:p></o:p>[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Calibri] MsgBox "Please only make one entry per row"<o:p></o:p>[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Calibri] Range("D" & RowNum + 1, Range("D" & RowNum + 2)).EntireRow.Delete<o:p></o:p>[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Calibri]End If<o:p></o:p>[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Calibri]End If<o:p></o:p>[/FONT][/COLOR][/SIZE]
[SIZE=3][COLOR=#000000][FONT=Calibri]End Sub<o:p></o:p>[/FONT][/COLOR][/SIZE]