×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Listbox & Labelbox

Listbox & Labelbox

Listbox & Labelbox

(OP)
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

RE: Listbox & Labelbox

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



 

RE: Listbox & Labelbox

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources