![](/img/trans.png)
[英]Checking one cell against two columns in two other sheets in the same workbook and showing two outputs
[英]checking if cell value exists in two other sheets
我試圖在幾個不同的工作表中跟蹤ID,我希望能夠為一個標准提供True值,為另一個標准提供false。 這是我想要完成的偽代碼。
IF sheet1.A1.value EXISTS AND DOES NOT EXIST IN sheet2.A:A OR sheet3.A:A
THEN RETURN "true"
ELSE RETURN "false"
嘗試這個
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
你也可以用這樣的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")
本讀:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.