If Search that Exits Sub or Ends If

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Sheet1 D8 will be the value that I am searching for.

Sheet2 Column B is the location of all cell values that I want to search.

Trying to imbed this function in a macro to do the following.

(Granted I may have to use something other than just an If function but
that's why I'm posting) =)

If value in Sheet1 D8 = any of the cell values in Sheet2 Column B Then
MsgBox "Try again."
Exit Sub
Else
End If

I just can't seem to find the proper setup that I am looking for. Any help
would be greatly appreciated!

Thank you!
 
Here you go. Not too sure why you need the Exit Sub since you have the if
statement to control the flow of exectuins but to each his own...

If Application.WorksheetFunction.CountIf(Sheets("Sheet2").Columns("B"), _
Sheets("Sheet1").Range("D8").Value) >= 1 Then
MsgBox "Try Again"
Else

End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top