【发布时间】:2015-07-08 23:42:33
【问题描述】:
我在工作表 1 上有值,我使用条件格式给出了背景颜色。
我只想复制颜色并将其粘贴到工作表 2 的相应单元格而不粘贴值。
例如,如果工作表 1 单元格 A1 具有特定值的红色,则将颜色转移到工作表 2 A1。
我使用两种颜色,红色和白色。红色代表较高的价值,白色代表较低的价值。
Sub copycolor()
Dim intRow As Integer
Dim rngCopy As Range
Dim rngPaste As Range
For intRow = 1 To 20
Set rngCopy = Sheet1.Range("A" & intRow + 0)
Set rngPaste = Sheet2.Range("b" & intRow)
'Test to see if rows 500+ have a value
If rngCopy.Value <> "" Then
'Since it has a value, copy the value and color
rngPaste.Value = rngCopy.Value
rngPaste.Interior.Color = rngCopy.Interior.Color
End If
Next intRow
End Sub
【问题讨论】:
-
条件格式简单吗?我在考虑而不是复制颜色。检查该值是否满足条件格式,如果满足则将 rngPaste 颜色更改为该颜色