复制超链接单元格之间的条件格式化 [英] copy conditional formatting between hyperlinked cells

查看:191
本文介绍了复制超链接单元格之间的条件格式化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确保单元格的条件格式也可以应用于其超链接单元格?

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

这篇关于复制超链接单元格之间的条件格式化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆