Jmoz092
Board Regular
- Joined
- Sep 8, 2017
- Messages
- 184
- Office Version
- 365
- 2011
- Platform
- Windows
- MacOS
I have a similar question as posed in this thread:
Advanced search
about this code:
How can I use this to search on a hidden sheet and have the user's selection autofill into the next available empty cell in a range on the user's active sheet? I'd like for a partial search to initiate a response in the search box.
For example:
user searches for "app"
search box gives list of responses (that contain "app" anywhere in the full string) that will decrease as the input string lengthens and becomes more specific.
Advanced search
about this code:
Code:
[COLOR=#454545][FONT="][SIZE=2]Sub searchVal()[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] Application.ScreenUpdating = False[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] Dim foundVal As Range[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] Dim sAddr As String[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] Dim response As String[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] response = InputBox("Please enter the value to search.")[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] With ActiveSheet.UsedRange[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] Set foundVal = .Find(response, LookIn:=xlValues, lookat:=xlWhole)[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] If Not foundVal Is Nothing Then[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] sAddr = foundVal.Address[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] Do[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] foundVal.EntireRow.Interior.ColorIndex = 3[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] Set foundVal = .FindNext(foundVal)[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] Loop While foundVal.Address <> sAddr[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] sAddr = ""[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] Else[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] MsgBox ("Value not found. Please try again.")[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] End If[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] End With[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] Set foundVal = Nothing[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2] Application.ScreenUpdating = True[/SIZE][/FONT][/COLOR]
[SIZE=2][/SIZE][COLOR=#454545][FONT="][SIZE=2]End Sub[/SIZE][/FONT][/COLOR]
How can I use this to search on a hidden sheet and have the user's selection autofill into the next available empty cell in a range on the user's active sheet? I'd like for a partial search to initiate a response in the search box.
For example:
user searches for "app"
search box gives list of responses (that contain "app" anywhere in the full string) that will decrease as the input string lengthens and becomes more specific.