复制超链接单元格之间的条件格式化
如何确保单元格的条件格式也可以应用于其超链接单元格?
How do I ensure the conditional formatting of a cell is also applied to its hyperlinked cell as well?
以下是我正在尝试做的一个基本例子。单元格E6具有条件格式。单元M7超链接到单元格E6。如何确保M7的格式与E6相同?
following is a basic example of what I am trying to do. Cell E6 has conditional formatting. Cell M7 is hyperlinked to cell E6. How do I ensure that M7 has the same formatting as E6?
使用 Hyperlink.SubAddess 以获得其目标范围的引用。下一步复制目标范围,并使用
Hyperlink.PasteSpecial xlPasteFormats
复制所有格式。如果你只是想要条件格式化,那么你必须在目标的FormatConditions上执行。
Use Hyperlink.SubAddess
to get a reference to its target range. Next copy the target range and use Hyperlink.PasteSpecial xlPasteFormats
to copy all the formating over. If you just want the Conditional Formatting then you'll have to itererate over the target's FormatConditions.
Sub ProcessHyperlinks()
Dim h As Hyperlink
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
For Each h In ws.Hyperlinks
If h.SubAddress <> "" Then
On Error Resume Next
h.Range.FormatConditions.Delete
Range(h.SubAddress).Copy
h.Range.PasteSpecial xlPasteFormats
On Error GoTo 0
End If
Next
Next
End Sub