Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Selections fill a form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jennifer - 28 Nov 2007 07:39 GMT
Hi Guys,
I have a listbox that the user can make any number of selections
(multiSelect)then click the cmdSelect button and have it fill another form
with labels from the selections. The following code uses the selections but
on the form i have to have say 10 labels already set up to be filled and i
don't always need 10. I may only need to fill 3 labels with the selections
from the list box. Across from the labels i want to have textbox for the user
to enter a value. Have any ideas or have i confused everyone. Thank you so
much for any help or direction.

Private Sub cmdSelect_Click()
Dim i As Long
Dim SelCount As Long

With ListBox1
   For i = 0 To .ListCount - 1
       If .Selected(i) = True Then
           SelCount = SelCount + 1
           UserForm1.Controls("Label" & SelCount).Caption = .List(i)
       End If
   Next
End With

UserForm1.Show
End Sub
Signature

Thank you,

Jennifer

Joel - 28 Nov 2007 12:03 GMT
You don't need selcount because it is "i + 1" .  I believe you can make the
controls visible or not visible.

Private Sub cmdSelect_Click()
Dim i As Long

With ListBox1
   For i = 0 To .ListCount - 1
       If .Selected(i + 1) = True Then
           UserForm1.Controls("Label" & (i + 1)).Caption = .List(i)
           UserForm1.Controls("Label" & (i + 1)).visible = True
       else
           UserForm1.Controls("Label" & (i + 1)).visible = False
       End If
   Next
End With

UserForm1.Show
End Sub

> Hi Guys,
> I have a listbox that the user can make any number of selections
[quoted text clipped - 21 lines]
> UserForm1.Show
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.