Conditional Formatting rules are cleared out after running the code

LeanneBG

Board Regular
Joined
Jun 20, 2016
Messages
157
Hi Experts - i have a problem with my code. I have a conditional formatting rules i set that highlights the cell if it has a value of FALSE or DUPLICATE. It works right after i set the rules however the rules get deleted after running below code. Do the rules get deleted by any of the codes below? Not sure why. Can someone help please? Thank you!

Code:
Sub Clear()
Application.ScreenUpdating = False
Dim Ws As Worksheet
Dim Last_Row As Long
Dim Formula_Row As Long
Dim Last_RowM As Long




Sheets("Check").Select


ActiveSheet.AutoFilterMode = False


''This is solid for Advanced Filter:


On Error Resume Next
ActiveSheet.ShowAllData
Err.Clear


Last_Row = Range("A" & Rows.Count).End(xlUp).Row
If Last_Row > 1 Then Range("A2:H" & Last_Row).Clear




Formula_Row = Range("AAE" & Rows.Count).End(xlUp).Row
If Formula_Row > 2 Then Range("ZZ3:AAH" & Formula_Row).Clear




ActiveSheet.[A1].Select


Sheets("SRPT").Select


ActiveSheet.AutoFilterMode = False


''This is solid for Advanced Filter:


On Error Resume Next
ActiveSheet.ShowAllData
Err.Clear


Last_Row = Range("A" & Rows.Count).End(xlUp).Row


If Last_Row > 1 Then
Range("A2:K" & Last_Row).Clear
Range("M2:S" & Last_Row).Clear
End If


Last_RowM = Range("M" & Rows.Count).End(xlUp).Row


If Last_RowM > 1 Then
Range("A2:K" & Last_RowM).Clear
Range("M2:S" & Last_RowM).Clear
End If


ActiveSheet.[A1].Select


Sheets("MENU").Select
MsgBox "All sheets are cleared, you may now proceed with checks"


Application.ScreenUpdating = True
End Sub
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.

Forum statistics

Threads
1,224,823
Messages
6,181,175
Members
453,021
Latest member
Justyna P

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