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

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

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
You could change this line:
VBA Code:
If answer = vbYes Then
to this:
VBA Code:
If answer = vbYes And r >= 4 Then
 
Upvote 0
@Fluff

With regards the locked post see screen shot I was told you have a draft in place & i had to wait 74 seconds.
Once 74 seconds was up the post then posted itself.
 

Attachments

  • EaseUS_2024_07_19_20_07_54.jpg
    EaseUS_2024_07_19_20_07_54.jpg
    36 KB · Views: 5
Upvote 0
Draft posts do not get sent automatically, also you should have to wait for any period of time.
 
Upvote 0

Forum statistics

Threads
1,223,713
Messages
6,174,043
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