Я нашел решение жестко закодировать эффекты условного форматирования, и оно работает в определенной степени. Исходный код прилагается, а также мой адаптированный код. Мой адаптированный код теперь жестко кодирует цвета и узоры, но я не могу заставить его работать с градиентными цветами.
Оригинал (это работает, но мои потребности требуют включения узоров и градиентов) Источник:Сохраните примененные форматы условного форматирования
'this block will hard code the applied conditional formatting
For Each cell In rng
If cell.DisplayFormat.Interior.ColorIndex <> xlNone Then
cell.Interior.Color = cell.DisplayFormat.Interior.Color
End If
Next cell
Я адаптировал это также к шаблонам жесткого кода, которые работают. Но жесткое кодирование градиентов не работает. Этот бит, который не работает, окружен комментарием.
'this block will hard code the applied conditional formatting
For Each cell In rng
If cell.DisplayFormat.Interior.ColorIndex <> xlNone Then
With cell.Interior
.Color = cell.DisplayFormat.Interior.Color
.Pattern = cell.DisplayFormat.Interior.Pattern
'*********** THIS BIT DOESN'T WORK**************
.Gradient.Degree = cell.DisplayFormat.Interior.Gradient.Degree
'.Gradient.ColorStops.Clear
With Gradient.ColorStops.Add(0)
.Color = cell.DisplayFormat.Interior.Gradient.ColorStops.Add(0).Color
.TintAndShade = cell.DisplayFormat.Interior.Gradient.ColorStops.Add(0).TintAndShade
End With
With Gradient.ColorStops.Add(1)
.Color = cell.DisplayFormat.Interior.Gradient.ColorStops.Add(1).Color
.TintAndShade = cell.DisplayFormat.Interior.Gradient.ColorStops.Add(1).TintAndShade
End With
'*********** THIS BIT DOESN'T WORK**************
End With
End If
Next cell
Любая помощь, которая поможет мне найти решение, будет оценена по достоинству.


With .Gradient точка необходима для определения родительского объекта
Add — это метод, используйте ColorStops(1).Color, чтобы получить стоимость имущества
For Each cell In rng
If cell.DisplayFormat.Interior.ColorIndex <> xlNone Then
Set CFInte = cell.DisplayFormat.Interior
With cell.Interior
.Color = CFInte.Color
.Pattern = CFInte.Pattern
Set CFGrad = CFInte.Gradient
.Gradient.Degree = CFGrad.Degree
'.Gradient.ColorStops.Clear
With .Gradient.ColorStops.Add(0)
.Color = CFGrad.ColorStops(1).Color
.TintAndShade = CFGrad.ColorStops(1).TintAndShade
End With
With .Gradient.ColorStops.Add(1)
.Color = CFGrad.ColorStops(2).Color
.TintAndShade = CFGrad.ColorStops(2).TintAndShade
End With
End With
End If
Next cell
Извините, я не знал, что могу восстановить удаление. Я тоже не увидел ответа, пока не удалил пост.