Reputation: 2954
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. 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"
Upvotes: 0
Views: 11316
Reputation: 5439
You could also do this with just an excel formula like this:
=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:
Upvotes: 1
Reputation: 149287
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
Upvotes: 1