Macro to prevent user from deletion specific rows contains words

MKLAQ

Active Member
Joined
Jan 30, 2021
Messages
397
Office Version
  1. 2016
Platform
  1. Windows
Hello
I search for macro to prevent user from deletion specific rows , but the user can edit them .
so shouldn't delete rows 54,55,56 at all , also in rows for column C contains words( PAID , DISCOUNT ,NET ) should not delete them totally .
when try deleting rows the range will be A54:H
thanks
 
I will see the link, but I'm not sure if I can adapt based on my requirements.
 
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I will see the link, but I'm not sure if I can adapt based on my requirements.
You should be able to copy and use that code "as-is". You do not need to edit that. That disables ALL manual deletion of rows.

In theory, then you just need to build a new VBA procedure that prompts the user to enter which rows they would like to delete.
You can code it to follow whatever rules you need to determine whether or not those rows can be deleted or not, then delete them in the code, or tell them those rows cannot be deleted.
You could then assign a button to this code, and this code would be the only way for them to delete rows in the workbook.
 
Upvote 0
thanks for this link .
well, it delete any rows , but I need to set specific rows contains words and specific numbers, moreover use undo this means the user can't edit it , just prevent delete without prevent editing in my case .
 
Upvote 0
It seems that you are only reading half of my replies.
As I mentioned in both of my last two posts, there are 2 parts to my suggestion:
1. Use the code I referenced to prevent the manual deletion of ALL rows
2. Create your own interactive macro that they must use to delete rows

So essentially, you are forcing them to use your custom macro if they want to delete any rows, where you can control which rows are allowed to be deleted.
 
Upvote 0
Joe , in reality I try to understand the part2 but I don't understand you sorry!
anyway thanks for your time . I hope else body see my requirements
 
Upvote 0
Joe , in reality I try to understand the part2 but I don't understand you sorry!
anyway thanks for your time . I hope else body see my requirements
You said you file has "many codes" (I assume meaning VBA code).
I was assuming that if your file has a lot of VBA code, you would know at least a little bit about writing VBA code, as it would not typically be wise to load up a file with a ton of VBA code if you don't understand it and cannot support it.

What is your level of VBA code writing?
If you are not comfortable writing/supporting VBA code, I would highly recommend considering using the built-in tools, like Sheet Protection, that do not require any code.
 
Upvote 0
Hello
I search for macro to prevent user from deletion specific rows , but the user can edit them .
so shouldn't delete rows 54,55,56 at all , also in rows for column C contains words( PAID , DISCOUNT ,NET ) should not delete them totally .
when try deleting rows the range will be A54:H
thanks
What do you mean by deleting the row?
deleting the actual row or deleting the cell content in the row?
 
Upvote 0
@Akuini
I mean deleting the whole row when select it and try to delete it.
Let's say you want to prevent row 10 to be deleted.
Is it allowed to shift the row upward, say it become row 9?
What I mean is this: if say you delete row 2 then row 10 will be shift upward.
If it's not allowed then you actually need to also prevent all row above it to be deleted, not just row 10.
 
Upvote 0
@Akuini
yes it will change the row is preventing from deletion in location in upward. but not in all of cases
if I want preventing deletion row12 (I don't want deleting before row12) and I want delete row13,14 I supposes the row12 keep without moving ,right?
and if I want preventing delete row 20 , I want deleting row 19 , yes then will move row20 upward to become to row19
 
Upvote 0

Forum statistics

Threads
1,215,101
Messages
6,123,096
Members
449,095
Latest member
gwguy

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