gheyman
Well-known Member
- Joined
- Nov 14, 2005
- Messages
- 2,347
- Office Version
- 365
- Platform
- Windows
I have a Userform (Userform3) that has a ListBox (ListBox3) on it. The User is to select one or more items from the list and when they click the "Select" button (CommandButton1_Click) the selections from the ListBox is supposed to populate a table I have on a tab named Selected Tasks.
My issue is that it is only placing one of the selections in the table on tab Selected Tasks.
How can I modifiy this so that all selections are placed in the table. (FYI the table name is: Selected_Tasks)
Thanks for the Help
My issue is that it is only placing one of the selections in the table on tab Selected Tasks.
How can I modifiy this so that all selections are placed in the table. (FYI the table name is: Selected_Tasks)
Thanks for the Help
Code:
Private Sub CommandButton1_Click()
'Identifying Task(s)
'First Clear table
With Sheets("Selected Tasks").ListObjects("Selected_Tasks")
'Check If any data exists in the table
If Not .DataBodyRange Is Nothing Then
'Clear Content from the table
.DataBodyRange.ClearContents
End If
End With
'User Selects the Task(s)that they want the Cost Source, they are about to identify, to be applied to
'Move Selections to Tab: Selected Tasks
ListBox3.MultiSelect = fmMultiSelectMulti
'Loop through every item in the ListBox
For i = 0 To ListBox3.ListCount - 1
'Check if the item was selected.
If ListBox3.Selected(i) Then
'This if section is determining if there was a selection
'Put all selected items in Column A
With Sheets("Selected Tasks")
If Len(.Range("A2").Value) = 0 Then
.Range("A2").Value = ListBox3.List(i, 10)
Else
.Range("A" & .Rows.Count).End(xlUp).Offset(1).Value = ListBox3.List(i, 10)
End If
End With
End If
Next i
UserForm3.Hide
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
UserFormX.Show vbModeless
UserFormX.LabelProg.Width = 125
UserFormX.LabelProg.Caption = "63%"
DoEvents
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'Refresh Source Selection
'RefreshCostSource
Sheets("3 Source Selection").ListObjects(2).QueryTable.Refresh BackgroundQuery:=False
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
UserFormX.LabelProg.Width = 185
UserFormX.LabelProg.Caption = "97%"
DoEvents
UserFormX.Hide
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Sheets("3 Source Selection").Activate
MsgBox "In the table; select the row that has the Cost Source that you would like to use for this part and its identified task(s)"
End Sub
Private Sub CommandButton2_Click()
UserForm3.Hide
End Sub
Private Sub ListBox3_Click()
End Sub