简体   繁体   English

VBA检查两列中的单元格值

[英]VBA Check cell values in two columns

I am looking for a solution to the following Problem. 我正在寻找以下问题的解决方案。 I have a table with 2 columns and I need a macro to check if the rows that have same values in first column, also have the same values in another column and give an error message if not. 我有一个包含2列的表,并且我需要一个宏来检查第一列中具有相同值的行,另一列中是否具有相同值,如果没有则给出错误消息。 For example, 例如,

   1. a 12
   2. b 1
   3. c 567
   4. a 12
   5. c 567
   6. c 567
   7. b 1 

If for example in the 7. row the value in the second column is "2", then the error message will appear. 例如,如果在7.行中第二列的值为“ 2”,则将出现错误消息。 Any ideas how to do that? 任何想法如何做到这一点?

根据公式使用数据验证作为“自定义”:

=isnumber(match(<relative cell address of top cell>, $a:$a, 0))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM