Thread: vba:Userform
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips[_6_] Bob Phillips[_6_] is offline
external usenet poster
 
Posts: 11,272
Default vba:Userform

Alex,

Here is some code

Dim arysheets

Private Sub CommandButton1_Click()
Dim i As Long
Dim j As Long

With Me.ListBox1
For i = 0 To .ListCount - 1
If .Selected(i) Then
j = j + 1
If j = 1 Then
ReDim arysheets(1 To 1)
Else
ReDim Preserve arysheets(1 To j)
End If
arysheets(j) = .List(i)
End If
Next i
End With

End Sub

Private Sub UserForm_ACtivate()
Dim sh As Worksheet
For Each sh In ActiveWorkbook.Worksheets
Me.ListBox1.AddItem sh.Name
Next sh
End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Alex" wrote in message
...
I'd like to know how to make a userform that tells the

user to "Select Worksheets". Worksheet will be displayed

in the listbox as selected. Selected Worksheets will be

stored in an array for future processing, when command

button (Done) is click. Thanks in advance.