[英]checking if cell value exists in two other sheets
I am trying to track IDs within several different sheets and I want to be able to give a True value for one criteria and false for another. 我试图在几个不同的工作表中跟踪ID,我希望能够为一个标准提供True值,为另一个标准提供false。 Here is my pseudo code for what I am trying to accomplish.
这是我想要完成的伪代码。
IF sheet1.A1.value EXISTS AND DOES NOT EXIST IN sheet2.A:A OR sheet3.A:A
THEN RETURN "true"
ELSE RETURN "false"
Try this 尝试这个
Sub Sample()
Dim SearchString As String
SearchString = "Blah"
If Application.WorksheetFunction.CountIf(Sheets("Sheet1").Columns(1), SearchString) > 0 And _
Application.WorksheetFunction.CountIf(Sheets("Sheet2").Columns(1), SearchString) = 0 And _
Application.WorksheetFunction.CountIf(Sheets("Sheet3").Columns(1), SearchString) = 0 Then
'~~> Display relevant message
Else
'~~> Display relevant message
End If
End Sub
You could also do this with just an excel formula like this: 你也可以用这样的excel公式来做到这一点:
=IF(AND(len('Sheet1'!A1)>0 , ISERROR(MATCH('Sheet1'!A1,'Sheet2'!A:A,0)), ISERROR(MATCH('Sheet1'!A1,'Sheet3'!A:A,0))) , "True", "False")
This Reads: 本读:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.