Excel Visual Basic User Form - Search Box Entry Error Validation

KH0

New Member
Joined
Sep 17, 2011
Messages
2
Dear All,

This is my first post here so wish me luck ;)

I have a Excel Visual Basic User Form Search Box where I would like a MsgBox to appear when the user enters a search where there is no match found.

Thank You.

Code:
Private Sub EditCommandButton_Click()
Range("A:A").Select
If ProjectTextBox.Value = "" Then
MsgBox "Invalid Entry", vbCritical, "INVALID ENTRY"
Else
Selection.Find(What:=ProjectTextBox, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext).Activate
Me.Hide
ProjectTextBox.Value = ""
TechnicalTestLogEdit.Show
End If
End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Maybe

Code:
Private Sub EditCommandButton_Click()
Dim Found As Range
If ProjectTextBox.Value = "" Then
MsgBox "Invalid Entry", vbCritical, "INVALID ENTRY"
Else
Set Found = Columns("A").Find(What:=ProjectTextBox.Value, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext)
If Found Is Nothing Then
    MsgBox "Not Found", vbExclamation
    Unload Me
    Exit Sub
End If
Found.Select
Me.Hide
ProjectTextBox.Value = ""
TechnicalTestLogEdit.Show
End If
End Sub
 
Upvote 0
Maybe

Code:
Private Sub EditCommandButton_Click()
Dim Found As Range
If ProjectTextBox.Value = "" Then
MsgBox "Invalid Entry", vbCritical, "INVALID ENTRY"
Else
Set Found = Columns("A").Find(What:=ProjectTextBox.Value, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext)
If Found Is Nothing Then
    MsgBox "Not Found", vbExclamation
    Unload Me
    Exit Sub
End If
Found.Select
Me.Hide
ProjectTextBox.Value = ""
TechnicalTestLogEdit.Show
End If
End Sub

That Was FAST :outtahere:

Thank You So Much VoG That Did The Trick :grin:

I Appreciate It.
 
Upvote 0

Forum statistics

Threads
1,224,534
Messages
6,179,391
Members
452,909
Latest member
VickiS

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top