Here is what I am trying to accomplish.
I have a listbox (lbProducts) with a list of products and a set of 10 textboxes (txtProduct1 to txtProduct10) There is a CommandButton (btnSelect) in between listbox and textboxes.
So, when the user clicks on an object in listbox and clicks on "btnSelect", the select object is copied to next available textbox, starting from txtProduct1.
In short I want to allow user to select upto 10 objects from listbox and copy them to txtProduct 1 to txtProduct 10 which eventually will go into inputdata sheet.
Please find the attached workbook for reference.
Please Advise.
Last edited by himanshu83; 09-14-2010 at 03:23 PM.
Hello himanshu83,
Here is the code for the UserForm. Clear all the code you have now and paste this into the UserForm.
Option Explicit Private Sub btnCancel_Click() Unload Me End Sub Private Sub btnOk_Click() End Sub Private Sub btnSelect_Click() Dim Ctrl As Object For Each Ctrl In Me.Controls If Ctrl.Name Like "txtProduct#*" Then If Ctrl.Value = "" And lbProducts.ListIndex > -1 Then Ctrl.Value = lbProducts.List(lbProducts.ListIndex) Exit Sub End If End If Next Ctrl End Sub
Sincerely,
Leith Ross
Remember To Do the Following....
1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.2. Thank those who have helped you by clicking the Starbelow the post.
3. Please mark your post [SOLVED] if it has been answered satisfactorily.
Old Scottish Proverb...
Luathaid gu deanamh maille! (Rushing causes delays!)
Thanks a Lot Keith.. The code workes like magic
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks