简体   繁体   English

在if check中复制值时如何复制条件格式?

[英]How to copy conditional formatting when copying value within if check?

I have a check such as 我有一张支票,例如

=IF(A1="","",Sheet2!A1)

Where Sheet2!A1 contains a conditional formatted cell (colored a specific color) 其中Sheet2!A1包含条件格式的单元格(为特定颜色上色)

I want to keep the color on my new sheet 我想在新纸上保留颜色

How can I copy the cell, its value and its formatting? 如何复制单元格,其值和格式?

Can this be accomplished within a formula or is there something in VBA I can write that will do this 可以在公式中完成此操作,还是可以在VBA中写一些东西来做到这一点?

Can this be accomplished within a formula?

AFAIK, I don't think you can do this using excel formula AFAIK,我认为您无法使用excel公式执行此操作

VBA Code: VBA代码:

Select the cell where you had the formula and run the macro 选择具有公式的单元格并运行宏

Sub ColorCopyCell()
If (IsEmpty(ActiveCell)) Then 'If empty
Worksheets(2).Range(ActiveCell.Address).Copy
Selection.PasteSpecial Paste:=xlPasteAll
End If
End Sub

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM