Delete row but only after row 4, i have a code in use to edit

Status
Not open for further replies.

ipbr21054

Well-known Member
Joined
Nov 16, 2010
Messages
5,726
Office Version
  1. 2007
Platform
  1. Windows
I am using the code bellow but would like it to only delete the row if its after row 4.
Dont wish to delete row 1,2 or 3

Thanks

VBA Code:
Private Sub DeleteRow_Click()
Dim answer As Integer
Dim r As Long
If ActiveCell.Column = 1 Then
r = ActiveCell.Row '**************
answer = MsgBox("DELETE CUSTOMERS ROW " & ActiveCell.Value, vbYesNo + vbCritical, "DELETE CUSTOMERS ROW")
If answer = vbYes Then
ActiveCell.EntireRow.Delete
MsgBox "CUSTOMERS ROW NOW DELETED", vbInformation
Range("A2").Select
Range("A1").Select
End If
Else
MsgBox "YOU NEED TO SELECT A CUSTOMER IN COLUMN A", vbCritical, "SELECT CUSTOMER MESSAGE"
End If

End Sub
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Replace this block of code:
VBA Code:
ActiveCell.EntireRow.Delete
MsgBox "CUSTOMERS ROW NOW DELETED", vbInformation
With this block of code:
VBA Code:
If ActiveCell.Row >= 4 Then 
    ActiveCell.EntireRow.Delete
    MsgBox "CUSTOMERS ROW NOW DELETED", vbInformation
End If
 
Upvote 0
Solution
Status
Not open for further replies.

Forum statistics

Threads
1,223,714
Messages
6,174,044
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top