taysomraven
New Member
- Joined
- Aug 14, 2023
- Messages
- 12
- Office Version
- 365
- Platform
- 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:
The Conditional Formatting I'm using is as follows:
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.
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.