Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Listbox & Labelbox

Status
Not open for further replies.

Harley78

Electrical
May 8, 2007
77
I have a question and I am stumped.

I have a userform1 that is filled then when a label28 is pressed a userform pops up with a listbox (multi selection). and a label underneath for the merging of the selections. Now I am stuck trying to make this work and also how would I make it that the label on Userform1 = userform2 label.

Here is my code thus far, just can't seem to get it to work.
Private Sub Userform_Initialize()
With ListBox1
.MultiSelect = fmMultiSelectMulti
ListBox1.List = Sheet4.Range("AL2:AL166").Value
End With
End Sub


Private Sub OK_Click()
Dim I As Long
Dim strCont As String

For I = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(I) Then
strCont = strCont & ListBox1.List(I) & "//"
ListBox1.Selected(I) = False
End If
Next I
Label1.Caption = Left(strCont, Len(strCont) - 1)

Me.Range("CP" & Sel_Row).Value ' THIS SEEMS TO BE THE PROBLEM

Unload UserForm2
End Sub

If anyone can help me or give me a suggestion, I would greatly appreciate it.

Regards

Bill
 
Replies continue below

Recommended for you

Code:
Me.Range("CP" & Sel_Row).Value ' THIS SEEMS TO BE THE PROBLEM

The statement Me.Range("CP" & Sel_Row).Value might return something, but you are not doing anything with or to it. Also, I don't see how this is related to the stated goal.

I think there are more sophisticated ways, but a public variable should do the trick.

Code:
Somewhere in Userform1:

Public myLabelText as String

myLabelText = userform1.label28.text

Somewhere in Userform2:

userform2.label##.text = myLabelText



 
you might also try the eng-tips sister site tek-tips.com

They have a very active vba forum.

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor