I would to say thank you to RoyUK for helping me out with this DependantlistBoxes where a Userform has two columns.
Now I've manupilated a Userform so that whenever I double click on the cell, the selected text from the second box in Userform is pasted to the cell in the next column to the right.
But I what I really want it to do is to past the text fromt the first box in Userform to the active cell and when move to the second box in Userform, the selected text will be paste to the cell on the right.
Like I double click on B3 (in "Fullarton") sheet, a userform appear. When I choose CB from the first box in userform, it should paste in B3.
Then when I choose Electrician from second box in userform, Electrician should be paste in C3.
I have enclosed the file for you to see and hope there is a way to it
Thank you in advance
DependantlistBoxesShort.xls
Last edited by unley; 05-04-2009 at 06:00 PM.
Hello unley,
I changed two of the UserForm event procedures to paste the information into the ActiveCell and into the cell to the right of the ActiveCell. The changes shown have been added to the attached workbook.
When writing code for UserForm procedures, it is redundant to prefix a Control with the keyword Me and usually unnecessary. Since the code is being written for the UserForm module, VBA assumes the Control references belong to this module. This is equivalent to adding the UserForm name to the Control name.
'These 2 statements are equivalent... UserForm1.ListBox2.List = rSource.Value Me.UserForm1.LstBox2 = rSource.Value 'You can use this statement instead ListBox2.List = rSource.ValuePrivate Sub CommandButton1_Click() 'PASTE ActiveCell.Value = ListBox1.Value ActiveCell.Offset(0, 1) = ListBox2.Value End Sub Private Sub ListBox1_Click() Dim Col As Long Col = ListBox1.ListIndex + 1 With wsLists Set rSource = .Range(.Cells(2, Col), .Cells(.Rows.Count, Col).End(xlUp)) End With ListBox2.List = rSource.Value 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!)
thank you very much Leith Ross for your time with this.
Like I said before, I got so much to learn VBA with excel and now I have to work out UserForm with 3 columns.
So thank you again Leith, much appreciated
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks