【发布时间】:2015-01-08 05:18:40
【问题描述】:
假设我在哪里有 Sheet1
A B
1 foo foo
2 bar bar
和参考表在哪里
A
1 bar <-- cell is formatted with red background
2 foo <-- cell is formatted with blue background
以及在所有其他编程示例中,“bar”和“foo”是任意占位符值。 :)
我想让 Sheet1 中的每个单元格 (A1:D4) 与 ReferenceSheet (A1:A2) 中的定义单元格的值匹配,该单元格将自动复制定义单元格的格式。
因此,继续上面的示例,Sheet1 的背景颜色将被格式化为
A B
1 bl bl
2 red red
但如果我将 ReferenceSheet 的格式更改为
A
1 bar <-- cell is formatted with pink background
2 foo <-- cell is formatted with black background
Sheet1 的背景格式将更新为
A B
1 blk blk
2 pk pk
如果可能,如何实现这一点?
======
*我想在工作表中定义我的格式(而不是在 Visual Basic 代码中),以便创建更多用户可访问的格式定义。如果这不是一个选项,Visual Basic(因此是全局的)定义将是我的下一个选择。应用于每个单元格的大量复制条件格式将是我的最后选择,尽管找到类似于 Microsoft Word 中的样式的样式抽象选项将使其成为更容易选择的选择。
【问题讨论】:
-
你考虑过
Worksheet_ChangeSub吗?
标签: vba excel conditional-formatting