Hi there,
I can't seem to wrap my head around this... Basically i have create a worksheet with a textbox whereby when i search for a word it autofilters a selected column. I also have three option buttons that in theory, i would want a user to select whichever button and that would dictate where that textbox searches. I only have one text box and three different buttons.
What i found that happens is, if a user selects one button and types, it filters correctly, then if you select another one it keeps the first filter and applies a second. but i actually want it only to filter one at a time if that makes sense?
I've also attached a screenshot of the search bar textbox i have created.
Here's the code:
I can't seem to wrap my head around this... Basically i have create a worksheet with a textbox whereby when i search for a word it autofilters a selected column. I also have three option buttons that in theory, i would want a user to select whichever button and that would dictate where that textbox searches. I only have one text box and three different buttons.
What i found that happens is, if a user selects one button and types, it filters correctly, then if you select another one it keeps the first filter and applies a second. but i actually want it only to filter one at a time if that makes sense?
I've also attached a screenshot of the search bar textbox i have created.
Here's the code:
VBA Code:
Private Sub NameTextBox_DropButtonClick()
If ActiveSheet.OptionButton1 = True Then
ActiveSheet.ListObjects("Names").Range _
.AutoFilter Field:=19, Criteria1:="=*" & NameTextBox.Text & "*"
Else
End If
If ActiveSheet.OptionButton2 = True Then
ActiveSheet.ListObjects("Names").Range _
.AutoFilter Field:=17, Criteria1:="=*" & NameTextBox.Text & "*"
Else
End If
If ActiveSheet.OptionButton3 = True Then
ActiveSheet.ListObjects("Names").Range _
.AutoFilter Field:=18, Criteria1:="=*" & NameTextBox.Text & "*"
Else
End If
End Sub