prevent clear color by condition formatting

Hasson

Active Member
Joined
Apr 8, 2021
Messages
387
Office Version
  1. 2016
Platform
  1. Windows
hello

I use some colors by condition formatting when change or add new data but I don't want allow for anybody clear the color when enter condition formatting to clear the color by message box " you have not a permission do that" ,is it possible?
 
Last edited:

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Try protecting the worksheet, making sure that "Format cells" is unchecked.
 
Upvote 0
thanks but this is not a good choice because it protects and disable other properties , I would just disable condition formatting

is it possible by code or any other thing?
 
Upvote 0
AFAIK there is no way to independently lock conditional formatting but allow other formatting at the same time. It's either both or none.

However, If you record a macro applying the conditional formatting you want to your cells, you can call it with Worksheet_Change, as in this example, to essentially overwrite the existing formatting with the conditional formatting rule you want.

If the issue arrises because your users are copying/pasting into the sheet and messing up the conditional formatting, there's ways around that by forcing a paste special: values instead of regular paste, but if you're worried about just typing in values, the above link is probably best.
 
Upvote 0
it doesn't help it shows error
1.PNG
 
Upvote 0
However, If you record a macro applying the conditional formatting you want to your cells, you can call it with Worksheet_Change, as in this example, to essentially overwrite the existing formatting with the conditional formatting rule you want.
That link seems to have all sorts of errors with it.
In addition to the errors already pointed out, there is also no "ThisWorksheet" module in Excel.
There is a "ThisWorkbook" module, and inidividual sheet modules.

If you want to use something like that, you may want to reach out to Alan Wyatt and ask him if he can revise and correct all the errors in that post.
 
Upvote 0
That link seems to have all sorts of errors with it.
In addition to the errors already pointed out, there is also no "ThisWorksheet" module in Excel.
There is a "ThisWorkbook" module, and inidividual sheet modules.
I suppose that's what I get for not verifying the solutions that i link to. :/

@Hasson sorry for the bad link. If that is the angle you want to take, you might try something like this instead
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    Dim conditionalFormatRange As Range
    Set conditionalFormatRange = Me.Range("$B$3:$B$50")
    
    If Not Application.Intersect(Target, conditionalFormatRange) Is Nothing Then
        'call function that sets conditional formatting here from macro recorder
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,415
Messages
6,119,377
Members
448,888
Latest member
Arle8907

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