Я хочу зачитать цвет, который устанавливает условный формат для конкретной ячейки.
Пример, комментарий и код того, что я попробовал ниже. Примечание. Выделение - это просто ячейка, которая содержит условный формат.
Как я могу получить ссылку на FormatCondition
Объект? Что я пропускаю / не вижу? Ошибка в последней строке ...
Sub FC_Test()
Dim fc As FormatConditions
Dim fco As Object
Dim c As Object
Dim myRng As Range
Set myRng = Selection 'Any cell with a conditional format
Debug.Print "FC Count: " & myRng.Resize(1, 1).FormatConditions.Count
'Finds all FC on the sheet
Set fc = Cells.FormatConditions
Debug.Print TypeName(fc) 'Returns: FormatConditions
'Finds first applied format condition...
'...oddly this is not a FormatCondition (member of hte FC collection),
' but the name of the type of format condition applied.. i.e. "ColorScale", etc.
Set c = Cells.FormatConditions(1)
Debug.Print TypeName(c) 'Returns: ColorScale
'Finds FC in selected range.
Set fc = myRng.Resize(1, 1).FormatConditions
Debug.Print TypeName(fc) 'Returns: FormatConditions
Debug.Print TypeName(fc.Item(1)) 'Returns: ColorScale
Set fco = fc(1)
Debug.Print TypeName(fco) 'Returns: ColorScale
Set fco = Nothing
For Each fco In fc
Debug.Print TypeName(fco) 'Returns: ColorScale
Next fco
Dim fcs As FormatCondition
Set fcs = myRng.Resize(1, 1).FormatConditions(1) 'Type Mismatch:13
End Sub