General Ledger
Active Member
- Joined
- Dec 31, 2007
- Messages
- 460
Dear All,
I am trying to create a macro that will set the Lock check box to True for a cell if Conditional Formatting rule #1 for that cell is True.
I borrowed some code and ended up with the following that does not work correctly. This code never results in a True.
I don't understand the purpose of the r1c1Formula or the abFormula.
Any help?
Thanks,
GL
I am trying to create a macro that will set the Lock check box to True for a cell if Conditional Formatting rule #1 for that cell is True.
I borrowed some code and ended up with the following that does not work correctly. This code never results in a True.
I don't understand the purpose of the r1c1Formula or the abFormula.
Code:
Sub LockCellIfConditionalFormatTrue()
Dim cell As Range
On Error Resume Next
For Each cell In ActiveSheet.Range("a1:a3")
With cell
r1c1Formula = Application.ConvertFormula(Formula:=.FormatConditions(1).Formula1, _
fromreferencestyle:=Application.ReferenceStyle, _
toreferencestyle:=xlR1C1)
abFormula = Application.ConvertFormula(Formula:=r1c1Formula, _
fromreferencestyle:=xlR1C1, _
toreferencestyle:=Application.ReferenceStyle, _
toabsolute:=True, relativeto:=.Cells)
If Evaluate(abFormula) = False Then
Locked = False
Else
Locked = True
End If
End With
Next cell
End Sub
Any help?
Thanks,
GL