Hi,
I have a userform that people can use to search a datalist to return a possible match. The form has a combobox (SearchType, with options Item Code or Description), a textbox (SearchString), a command button (BeginSearch), and 2 textboxes (CodeReturn and DescriptionReturn)
At present the command button has the following code:
The ranges are on a sheet within the workbook. VLOOKUPTYPE and ItemCodeSearch are just for input form the macro - CodeReturn and DescReturn both have formula in as such:
The only difference between CodeReturn and DescReturn is the column numbers in the formula.
Right now the background is done, my problem.
I want to be able to cycle through possible matches on the userform. At the moment the formula + macro returns the top match, however for example:
If Paper is typed as a description search then it will return A4 Blue Paper x500, but then A4 Paper x500 might be what the user wants to get the code for.
Is there a way of building a macro into the userform (on new Buttons named NextSearch and BackSearch for example) that owuld move back and forwards through relevance?
Using Excel 2007
Long questions sorry! Many thanks for any replies!
I have a userform that people can use to search a datalist to return a possible match. The form has a combobox (SearchType, with options Item Code or Description), a textbox (SearchString), a command button (BeginSearch), and 2 textboxes (CodeReturn and DescriptionReturn)
At present the command button has the following code:
Code:
Private Sub BeginSearch_Click()
Range("VLOOKUPType").Value = SearchType
Range("ItemCodeSearch").Value = SearchString
Range("ItemCodeSearch").Select
With Selection
Selection.NumberFormat = "General"
.Value = .Value
End With
CodeReturn.Value = Range("CodeReturn")
DescriptionReturn.Value = Range("DescReturn")
End Sub
The ranges are on a sheet within the workbook. VLOOKUPTYPE and ItemCodeSearch are just for input form the macro - CodeReturn and DescReturn both have formula in as such:
Code:
=IFERROR(IF(VLOOKUPType="","",IF(VLOOKUPType="Item Code",VLOOKUP("*"&ItemCodeSearch&"*",Datalist,1,FALSE),IF(VLOOKUPType="Description",VLOOKUP("*"&ItemCodeSearch&"*",ExtDataList,1,FALSE),""))),"Not Found")
The only difference between CodeReturn and DescReturn is the column numbers in the formula.
Right now the background is done, my problem.
I want to be able to cycle through possible matches on the userform. At the moment the formula + macro returns the top match, however for example:
If Paper is typed as a description search then it will return A4 Blue Paper x500, but then A4 Paper x500 might be what the user wants to get the code for.
Is there a way of building a macro into the userform (on new Buttons named NextSearch and BackSearch for example) that owuld move back and forwards through relevance?
Using Excel 2007
Long questions sorry! Many thanks for any replies!