Logo 
Search:

MS Office Answers

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds
  Question Asked By: Fahimah Khan   on Aug 31 In MS Office Category.

  
Question Answered By: Sammy Anderson   on Aug 31

This is a common problem every programmer faced
Use a FLAG (boolean type user  variable) inside  the loop  if any values match in
specified search  criteria change the value with TRUE or else False
Again, check outside the loop with a IF condition like:

Private Sub cmdReview_Click()
Range(Selection, Selection.End(xlToRight)).Select
Do Until ActiveCell.Value = ""
Review = txtName.Text

If Review = ActiveCell.Value Then
txtName.Text = Review
txtDate.Text = ActiveCell.Offset(0, 1)
txtID.Text = ActiveCell.Offset(0, 2)
bSearchFlag = TRUE
End If

ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlToRight)).Select
Loop
Range("A1").Select

'---- My Code
IF bSearchFlag = TRUE then
MsgBox "Value Found"
Else
MsgBox "Value Not Found"
End If
'--- End My Code
End Sub

Share: 

 

This Question has 1 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on VBA msgBox question Or get search suggestion and latest updates.


Tagged: