Gazza83
asked on
Vb help
Please can you help me alter the code on my workbook.
Basically I would like for the listbox to display the up/down arrows when the userform is opened. So was Textbox1 to equal blank, then the arrows would display along with the listed range.
The picture describes what I would like to achieve but currently I would have to input "A" to achieve this.
Also something weird happens if I type "A" into textbox1 and then press the down arrow on my keyboard and then down again, for some reason it jumps to "Akrotiri" as opposed to descending down the range i.e. "Albania"
Many thanks for your help!
Gary
gary-test4.xls
Basically I would like for the listbox to display the up/down arrows when the userform is opened. So was Textbox1 to equal blank, then the arrows would display along with the listed range.
The picture describes what I would like to achieve but currently I would have to input "A" to achieve this.
Also something weird happens if I type "A" into textbox1 and then press the down arrow on my keyboard and then down again, for some reason it jumps to "Akrotiri" as opposed to descending down the range i.e. "Albania"
Many thanks for your help!
Gary
gary-test4.xls
Should now start with the listbox loaded
Copy-of-gary-test4.xls
Copy-of-gary-test4.xls
ASKER
ASKER
Thanks Tom, I've tried the attached and it works on start up. The only thing is if I hit the down arrow on my keyboard twice, it jumps to Akrotiri as oppposed to moving through the 'drop down'
OK, test this out. It could be right. I have removed the TextBox1_Change event, copying the code to a FillListBox sub. This way, whenever the text box changes due to the list box being selected, it doesn't re-populate the list box. As for the keystrokes, I've called FillListBox on the KeyUp event of the TextBox, instead of the Change event.
Regards,
Rob.
gary-test4.xls
Regards,
Rob.
gary-test4.xls
ASKER
Hi Rob, the code on the file you uploaded works brilliantly, just how I want it. The one problem is that Textbox4 doesn't seem to work:-
the old code had something like:-
End If
Set rng1 = Sheets("DataSheet").Range( "D1:D300") .Find(Text Box1.Value , , xlValues, xlWhole)
If Not rng1 Is Nothing Then TextBox4.Value = rng1.Offset(0, 1)
the old code had something like:-
End If
Set rng1 = Sheets("DataSheet").Range(
If Not rng1 Is Nothing Then TextBox4.Value = rng1.Offset(0, 1)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many thanks for your help!
No problem. Thanks for the grade.
Regards,
Rob.
Regards,
Rob.
The reason the list box was changing is because when an item is selected, it also updates the text box for the selected value, resulting in it being cleared.
I have prevented that, but I don't know how it's going to go with identifying the selection now.
Regards,
Rob.
gary-test4.xls