gsheppar
Active Member
- Joined
- May 15, 2005
- Messages
- 281
I'm trying to run a userform that will allow me to click ok and paste the data into a data entry sheet which is running great. The only exception is that I have 2 listboxes that allow multiple selections, and I'd like to be able to have those selections show up all in one cell in the data.
The 2 listboxes that allow multiple selections are "assignedProject" and "Department". I already have the columns where I want them to be posted in the code below, I'm just not sure how to get the mutliple items to show up in the next available row in that column.
Here is the code:
The 2 listboxes that allow multiple selections are "assignedProject" and "Department". I already have the columns where I want them to be posted in the code below, I'm just not sure how to get the mutliple items to show up in the next available row in that column.
Here is the code:
Code:
Private Sub Ok_Click()
Dim iRow As Long
Dim ws As Worksheet
Set ws = Worksheets("Project Entry")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'check for a project to be entered
If Trim(Me.projectType.Value) = "" Then
Me.projectType.SetFocus
MsgBox "Please enter a project"
Exit Sub
End If
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.projectType.Value
ws.Cells(iRow, 2).Value = Me.Due.Value
ws.Cells(iRow, 3).Value = Me.Priority.Value
ws.Cells(iRow, 4).Value = Me.assignedProject.Value
ws.Cells(iRow, 5).Value = Me.projectStart.Value
ws.Cells(iRow, 6).Value = Me.projectDue.Value
ws.Cells(iRow, 7).Value = Me.projectCompletion.Value
ws.Cells(iRow, 9).Value = Me.Department.Value
ws.Cells(iRow, 10).Value = Me.projectNotes.Value
'clear the data
Me.projectType.Value = ""
Me.Due.Value = ""
Me.Priority.Value = ""
Me.assignedProject.Value = ""
Me.projectStart.Value = ""
Me.projectDue.Value = ""
Me.projectCompletion.Value = ""
Me.Department.SetFocus
Me.projectNotes.Value = ""
End Sub