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,832
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

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
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,224,760
Messages
6,180,816
Members
452,996
Latest member
nelsonsix66

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