Home > Enterprise >  Get a Warning message box
Get a Warning message box

Time:05-03

I am working on a project and need help with VBA. As shown in the table attached, what I need is VBA code that would alert me if any the value in column B (SBO) is FALSE. I tried the code below but it is not giving me desired result so I would appreciate if anyone can help. Thanks!

Sub SBO_Lookup()
Sheets("Sheet1").Select
If Sheet1.Range("B:B").Value = "FALSE" Then
MsgBox "False SBO detected"
End If
End Sub

enter image description here

CodePudding user response:

You could use Range.Find() method:

If Sheet1.Range("B:B").Find("False") Is Not Nothing Then
    MsgBox "False SBO Detected"
End If

You could also use WorksheetFunction.CountIf() method:

If WorksheetFunction.Countif(Sheet1.Range("B:B"), "FALSE") > 0 Then
    MsgBox "False SBO Detected"
End If

CodePudding user response:

Just do this:

If [match(false,b:b,0)] Then MsgBox "False SBO detected"
  • Related