ClearContents VBA is clearing my Conditional Formatting

taysomraven

New Member
Joined
Aug 14, 2023
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Hi there, I'm trying to figure out a way to clear cells without clearing the applied Conditional Formatting rules from those cells. Here's my code:

VBA Code:
Sub WipeSheet()
'
' WipeSheet Macro
' Wipes all entries in the sheet besides formulas
'
' Keyboard Shortcut: Ctrl+Shift+W
'
    PopupPrompt = MsgBox("Do you want to clear this sheet?", vbYesNo + vbExclamation + vbDefaultButton2, "CLEAR SHEET DATA")

    If PopupPrompt = vbNo Then
            Exit Sub
    End If
    
    Range("Table[Name]:Table[Birthdate]").ClearContents
    Range("$A$10").Activate


End Sub


The Conditional Formatting I'm using is as follows:

Excel Formula:
=INDIRECT("Table[@[Helper]]")="Yes"

and it's applied to $A:$W where Table resides.


Anyone have any thoughts on why this VBA would be clearing the conditional formatting of the cells it wipes? I was under the impression that the "Clear" VBA function would wipe contents and conditional formatting, but that "ClearContents" would preserve the conditional formatting.
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Turns out I'm a dummy and was pasting in text to the table which was overwriting the formatting. Pasting as values only corrected the issue. *sigh* At least I got it figured.
 
Upvote 0
Solution

Forum statistics

Threads
1,224,817
Messages
6,181,149
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