alexsheehan
Member
Hi there
I have a SearchBox (actually just a cell with a named range of "SearchBox") in my spreadsheet which allows the user to type a search term (obviously) which then restricts the results within my DataValidation drop-down cell to those items that meet the search criteria. Now what I want to achieve is to be able to set my validation box to the first item in the list that meets the search criteria UNLESS the user manually selects an item.
To break it down a little easier;-
I can manage to get the Validation Box to only show items that meet the criteria in my search box, however, as soon as someone searches for an item, I want the top item in the search list to display automatically at the top of the DataValidation drop down.
I can produce this effect myself with some code, however the problem I am having is when I manually change my DataValidation drop-down to another value, the code fires again automatically resetting the DataValidation drop-down back to the top value. Now I don't want it to do this, I want the code to fire as soon as the user searches for something, but then to stop until the next time the user searches for something.
Here's my code;-
[pre]
[/pre]
Maybe I need to use the code outside of the Worksheet_Change event? Please let me know if this makes sense or not, as I have been known to ramble!
Thanks folks
Alex
I have a SearchBox (actually just a cell with a named range of "SearchBox") in my spreadsheet which allows the user to type a search term (obviously) which then restricts the results within my DataValidation drop-down cell to those items that meet the search criteria. Now what I want to achieve is to be able to set my validation box to the first item in the list that meets the search criteria UNLESS the user manually selects an item.
To break it down a little easier;-
I can manage to get the Validation Box to only show items that meet the criteria in my search box, however, as soon as someone searches for an item, I want the top item in the search list to display automatically at the top of the DataValidation drop down.
I can produce this effect myself with some code, however the problem I am having is when I manually change my DataValidation drop-down to another value, the code fires again automatically resetting the DataValidation drop-down back to the top value. Now I don't want it to do this, I want the code to fire as soon as the user searches for something, but then to stop until the next time the user searches for something.
Here's my code;-
[pre]
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'
If Range("SearchBox").Value = "" Then
End If
Exit Sub
If Range("ValidationBox").Value <> Range("ValidationBoxFirstValue") And Range("SearchBox").Value <> "" Then
Range("ValidationBox").Value = Range("ValidationBoxFirstValue")
End If
End Sub
Maybe I need to use the code outside of the Worksheet_Change event? Please let me know if this makes sense or not, as I have been known to ramble!
Thanks folks
Alex