Hello, I can't delete the conditional formatting, please help, thanks. below is my code. My workbook got multi conditional formatting, cant del all in one time.
VBA Code:
Sub ReadingLayout()
'add sub code
sCode = "Private Sub Worksheet_SelectionChange(ByVal Target As Range)" & vbCrLf & _
"' *** Code Added By VBA ***" & vbCrLf & _
"If Application.CutCopyMode = False Then " & vbCrLf & _
"Application.Calculate" & vbCrLf & _
"End If" & vbCrLf & _
"End Sub" & vbCrLf
With ActiveWorkbook.VBProject.VBComponents(ActiveSheet.Name).CodeModule
NextLine = .CountOfLines + 1
.InsertLines NextLine, sCode
End With
'add formatcondition
Dim rng As Range
Dim FC1 As FormatCondition, FC2 As FormatCondition
Set rng = ActiveSheet.Range("A1:XFD9999")
Set FC1 = rng.FormatConditions.Add(xlExpression, Formula1:="=OR(CELL(""col"")=COLUMN(),CELL(""row"")=ROW())")
With FC1
.SetFirstPriority
.Interior.Color = RGB(252, 213, 181)
End With
End Sub
VBA Code:
Sub DelReadingLayout()
'del sub code
Dim CodeInd As Long, sNo, eNo, bFlag
Const PROC_NAME = "PRIVATE SUB WORKSHEET_SELECTIONCHANGE(BYVAL TARGET AS RANGE)"
bFlag = False
With ActiveWorkbook.VBProject.VBComponents("sheet1").CodeModule
For CodeInd = .CountOfDeclarationLines + 1 To .CountOfLines
Select Case VBA.UCase$(Trim(.Lines(CodeInd, 1)))
Case PROC_NAME
bFlag = True
sNo = CodeInd
Case "END SUB"
If bFlag Then
eNo = CodeInd
Exit For
End If
End Select
Next CodeInd
'For i = eNo To sNo Step -1
' .DeleteLines i
'Next
.DeleteLines sNo, eNo - sNo + 1
End With
[B][U]'del format (broken)[/U][/B]
Dim FC1 As FormatCondition
For Each FC1 In ActiveSheet.Cells.FormatConditions
If FC1.Interior.Color = RGB(252, 213, 181) Then
FC1.Delete
End If
Next FC1
End Sub