still learning
Well-known Member
- Joined
- Jan 15, 2010
- Messages
- 826
- Office Version
- 365
- Platform
- Windows
Hi
I have a user form that a user will enter a name into a text box
The userform also has three option buttons that the user will then click one
That name will be used to extract data from a table using advance filter
And the result will show in a list box in the same userform.
The range that the list box looks for data is AU2:BC2
If the filter does not show any results (because the name doesn’t match anything in the data source), I want to have a message box come up.
Here is the message box macro
Here is the macro for one of the option buttons (there are three)
Here is the birthday macro (which is the advance filter code)
I don’t know where to put the “noresults” message box
If the list box is empty because the query didn’t find a match I would like to let the user know that something is wrong.
Mike
I have a user form that a user will enter a name into a text box
The userform also has three option buttons that the user will then click one
That name will be used to extract data from a table using advance filter
And the result will show in a list box in the same userform.
The range that the list box looks for data is AU2:BC2
If the filter does not show any results (because the name doesn’t match anything in the data source), I want to have a message box come up.
Here is the message box macro
VBA Code:
Sub noresults ()
If Range("au2:BC2").Value = "" Then
MsgBox " NO RESULTS"
End If
End Sub
VBA Code:
Private Sub OptionButton1_Click()
With TextBox1 'birthdate
ActiveSheet.Range("wbirth").Value = .Text
End With
Me.Hide
birthday
Unload Me
End Sub
VBA Code:
Sub birthday()
' Query
Range("bdata").AdvancedFilter Action:=xlFilterCopy, CriteriaRange:=Range( _
"bcriteria"), CopyToRange:=Range("bextract"), Unique:=False
End Sub
I don’t know where to put the “noresults” message box
If the list box is empty because the query didn’t find a match I would like to let the user know that something is wrong.
Mike