Copy Format Conditions from one cell to another?

2019-09-21 01:15发布

I want to be able to write something like:

wks.Range("A1").FormatConditions = r.FormatConditions 

to copy conditional formatting from one cell to another. Is this possible to do? I want to copy conditional formatting from one cell to another by using one line of code, just like when I copy a formulas from one cell to another:

wks.Range("A1").Formula = r.Formula

Maybe there is a built-in command for this in VBA that I have not found? Maybe someone has written a custom sub for this?

r in the above examples is a range.

1条回答
Viruses.
2楼-- · 2019-09-21 02:05

I don't think you can do it using one line of code. However, you can do it using two lines:

wks.Range("A1").Copy
r.PasteSpecial xlPasteFormats

This will copy all the formatting including the format conditions.

查看更多
登录 后发表回答