Dr. Demento
Well-known Member
- Joined
- Nov 2, 2010
- Messages
- 618
- Office Version
- 2019
- 2016
- Platform
- Windows
I'm futzing around with Jeff Weir's Easy way to back up CF formats and I'm trying to create a list of CF that can then be read into a sub and applied on other workbooks. For the most part everything works out fine, but I'm having trouble with the FormatCondition.Operator Property. According to MSDN, it's supposed to "Returns a Long value that represents the operator for the conditional format." However, for the life of me I can't figure out what property to use to get the Operator value when reading the CF formats from a workbook.
I've tried object.Operator but I get RTE 1004 (application/object-defined error). I recognize there may not be any way to pull out the Operator, but never know . . .
The subs with tbl_ prefix have to do with putting the data in the table. They can be ignored.
I had to Dim cf as a generic Object instead of declaring as FormatCondition because DataBars screw things up.
' See When is a FormatCondition not a FormatCondition? | Excel Matters
Any thoughts?
Thanks y'all.
I've tried object.Operator but I get RTE 1004 (application/object-defined error). I recognize there may not be any way to pull out the Operator, but never know . . .
Code:
Dim obj As Object
Dim fc As FormatCondition
For Each obj In sht.Cells.FormatConditions
strAddress = Replace(obj.AppliesTo.address, "$", vbNullString) ' ~~ Removes "$"
Select Case TypeName(obj)
Case "FormatCondition"
Set fc = obj
tbl_addNewRow tbl
tbl_addData tbl, Now, 1 ' Timestamp
tbl_addData tbl, sht.name, 2 ' sht name
tbl_addData tbl, TypeName(fc), 3 ' Variable type
tbl_addData tbl, cfConditionType(fc.Type), 4 ' Type of CF
t[B]bl_addData tbl, fc.Operator, 5 ' Operator <-- Hut the wheck?[/B]
tbl_addData tbl, strAddress, 6 ' address
tbl_addData tbl, "'" & fc.Formula1, 7 ' Formula of CF
tbl_addData tbl, obj.StopIfTrue, 8 ' bln - Stop if True
End Select
Next obj
The subs with tbl_ prefix have to do with putting the data in the table. They can be ignored.
I had to Dim cf as a generic Object instead of declaring as FormatCondition because DataBars screw things up.
' See When is a FormatCondition not a FormatCondition? | Excel Matters
Any thoughts?
Thanks y'all.