在 Excel 脚本中使用条件格式代码中的编号列引用
Use numbered column references in Excel Conditional Formatting code in VBA script
我有一些 VBA 脚本可以在 Excel 中应用一些条件格式。
有没有一种方法可以引用列的数值而不是普通的单元格引用。
这是我目前拥有的:
"=AND(NOT(ISBLANK(F3)),F3<>""SomeValue1"",F3<>""SomeValue1"")"
这就是我想要实现的目标:
"=AND(NOT(ISBLANK(Cells(3,6))),Cells(3,6)<>""SomeValue1"",Cells(3,6)<>""SomeValue2"")"
Replace("=AND(NOT(ISBLANK({addr})),{addr}<>""SomeValue1"",{addr}<>""SomeValue2"")", _
"{addr}", Cells(3,6).Address)
我能够使用以下代码首先将列号转换为列字母来解决我的查询:
ColLetter = Split(Cells(1, ColNumber).Address, "$")(1)
一旦我有了这个转换值,我就可以在我的代码中使用这个变量来进行条件格式化:
"=AND(NOT(ISBLANK(" & ColLetter & "3))," & ColLetter & "3<>""SomeValue1""," & ColLetter & "3<>""SomeValue1"")"
感谢所有回复的人。
我有一些 VBA 脚本可以在 Excel 中应用一些条件格式。
有没有一种方法可以引用列的数值而不是普通的单元格引用。
这是我目前拥有的:
"=AND(NOT(ISBLANK(F3)),F3<>""SomeValue1"",F3<>""SomeValue1"")"
这就是我想要实现的目标:
"=AND(NOT(ISBLANK(Cells(3,6))),Cells(3,6)<>""SomeValue1"",Cells(3,6)<>""SomeValue2"")"
Replace("=AND(NOT(ISBLANK({addr})),{addr}<>""SomeValue1"",{addr}<>""SomeValue2"")", _
"{addr}", Cells(3,6).Address)
我能够使用以下代码首先将列号转换为列字母来解决我的查询:
ColLetter = Split(Cells(1, ColNumber).Address, "$")(1)
一旦我有了这个转换值,我就可以在我的代码中使用这个变量来进行条件格式化:
"=AND(NOT(ISBLANK(" & ColLetter & "3))," & ColLetter & "3<>""SomeValue1""," & ColLetter & "3<>""SomeValue1"")"
感谢所有回复的人。