【发布时间】:2017-04-25 12:50:06
【问题描述】:
请看下面两张图片 Sheet 1 和 Sheet 2
我正在尝试验证工作表 1“颜色”列中的值,即如果工作表 1“类型”是汽车,那么颜色只能是黑白。工作表 2 有什么类型的规则,哪些颜色可以有效。如果表格 1 中有任何其他颜色用于类型 Car,则相邻列应显示“颜色不匹配”。
for each cell in (sheet 1 - column color)
get type from (sheet 1 - column Type)
check if (Sheet 1 - column Type) is in (sheet 2 column Type),
if not give error in adjacent cell "No type"
if (Sheet 1 - column Type) is in (sheet 2 column Type) then
Check if (Sheet 1 - column color) has the valid color
if not give error "color not matching"
谁能告诉我如何在 excel VB 中做到这一点。
P.s,我知道如何使用 countifs 来做到这一点,但只是想知道如何在 Excel VB 中做到这一点
谢谢。
【问题讨论】:
-
COUNTIFS 和条件格式规则应该能够轻松做到这一点。
标签: vba excel validation