William C Johnson
asked on
How to use an input box variable in an Excel search function
How can you combine a variable with Excel 2007 Search function? I do not want the user to run the search directly so I want to search built by what he/she enters into an input box. Below is a sample sheet and macro.
Column A
Row1 TAR NBR
Row2 1
Row3 2
Row4 3
Row 5 4
Row 6 5
Row 7 6
Row 8 7
Row 9 8
Row 10 9
Row 11 10
Row 12 11
Range("A1").Select
Dim MyValue As Integer
Dim TARNbr As Integer
Prompt = "Search for which TAR?"
Caption = "Tell me..."
TARNbr = InputBox(Prompt, Caption, MyValue)
Cells.Find(What:="TARNbr", After:=ActiveCell, LookIn:=xlValues, LookAt:= _
xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
True, SearchFormat:=False).Activ ate
Column A
Row1 TAR NBR
Row2 1
Row3 2
Row4 3
Row 5 4
Row 6 5
Row 7 6
Row 8 7
Row 9 8
Row 10 9
Row 11 10
Row 12 11
Range("A1").Select
Dim MyValue As Integer
Dim TARNbr As Integer
Prompt = "Search for which TAR?"
Caption = "Tell me..."
TARNbr = InputBox(Prompt, Caption, MyValue)
Cells.Find(What:="TARNbr",
xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
True, SearchFormat:=False).Activ
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER