Mykasd
10-16-2007, 10:41 AM
For some reason I cannot get my userform to populate selected variables.
Here is my code:
Private Sub OKButton_Click()
'Capture DM(s)
Dim i As Long, NDMs As Integer, DM() As String
NDMs = 0
For i = 0 To DMList.ListCount - 1
If DMList.Selected(i) = True Then
NDMs = NDMs + 1
ReDim Preserve DM(NDMs)
DM(NDMs) = DMList.List(i, 0)
End If
Next i
Unload Me
End Sub
A pop up is supposed to appear showing what the user selected, but this is blank:
'InputsForm user form appears here to prompt user to select DMs
InputsForm.Show
MsgBox "The user chose the following DM(s): " & vbLf _
& Join(DM, vbLf), vbInformation, "User Inputs"
Then I try to create a worksheet tab by each DM name and it doesn't work. Code is:
'Creates new tabs for each DM selected
For i = 1 To NDMs
'Deletes worksheets for DMs that already exist, if user selects same trait again
'Dim sht As Worksheet
For Each sht In Worksheets
If sht.Name = DM(i) Then sht.Delete
Next
'adds new worksheet
Sheets.Add.Name = DM(i)
Next i
Can someone please help solve this problem. I need to be able to select DMs, have a pop up come up and show which have been selected, then populate tabs named after each DM.
Here is my code:
Private Sub OKButton_Click()
'Capture DM(s)
Dim i As Long, NDMs As Integer, DM() As String
NDMs = 0
For i = 0 To DMList.ListCount - 1
If DMList.Selected(i) = True Then
NDMs = NDMs + 1
ReDim Preserve DM(NDMs)
DM(NDMs) = DMList.List(i, 0)
End If
Next i
Unload Me
End Sub
A pop up is supposed to appear showing what the user selected, but this is blank:
'InputsForm user form appears here to prompt user to select DMs
InputsForm.Show
MsgBox "The user chose the following DM(s): " & vbLf _
& Join(DM, vbLf), vbInformation, "User Inputs"
Then I try to create a worksheet tab by each DM name and it doesn't work. Code is:
'Creates new tabs for each DM selected
For i = 1 To NDMs
'Deletes worksheets for DMs that already exist, if user selects same trait again
'Dim sht As Worksheet
For Each sht In Worksheets
If sht.Name = DM(i) Then sht.Delete
Next
'adds new worksheet
Sheets.Add.Name = DM(i)
Next i
Can someone please help solve this problem. I need to be able to select DMs, have a pop up come up and show which have been selected, then populate tabs named after each DM.