View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Chip Pearson Chip Pearson is offline
external usenet poster
 
Posts: 7,247
Default Populate form checkboxes from list

I would use a list box. With a Listbox named ListBox1, use code like
the following in the form's code module:

Private Sub UserForm_Initialize()
Dim WS As Worksheet
With Me.ListBox1
For Each WS In ThisWorkbook.Worksheets
.AddItem WS.Name
Next WS
.MultiSelect = fmMultiSelectExtended
.ListIndex = 0
End With
End Sub

Private Sub CommandButton1_Click()
Dim N As Long
Dim S As String
With Me.ListBox1
For N = 0 To .ListCount - 1
If .Selected(N) = True Then
S = S & .List(N) & vbCrLf
End If
Next N
End With
MsgBox S
End Sub


Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)

On Wed, 25 Feb 2009 10:51:01 -0800, Gaba
wrote:

Hi,
I'm working on a form that displays all the sheets on a workbook (so far 30,
the number can grow or shrink). The user will check which sheet(s) he/she
wants to save as a new file.
At the begining I was manually naming the checkboxes, now that the number of
sheets is growing, it became a waste of time.

Is there any way I can display automatically ALL sheets in a form? Can this
form be created on a sheet and hide the rest of the sheets? What is actually
doing is displaying just one sheet (with a menu button), click on the button
and displays the form, where the user selects which sheets to save. on click
the page displays. On unclick, goes hidden again.

Any ideas of better methods are more than welcome!
Thanks in advance