championem31
New Member
- Joined
- Aug 16, 2013
- Messages
- 3
So I have a VBA Userform with combo boxes and textboxes. I already had the combo boxes set up to populate a cell in the workbook as an array, but I'm having problems populating the next blank row. I have it set up for data entry, so a person could enter multiple events without exiting the form. However, the way its set up now, it occasionally overwrites data from an already filled out form. No fields are required. How can I get it to go to the next completely blank row? Right now I keep getting errors because it's stuck in a loop. Please help!!! Thank you!
Code:
Private Sub btnsave_click()
Dim irow As Long
Dim ws As Worksheet
Dim arrValues()
Set ws = Worksheets("13-14")
With ws
' find first blank row in database
irow = .Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).Row
.Cells(irow, 1).Value = Me.TypePresEvent.Value
.Cells(irow, 2).Value = Me.Topic.Value
.Cells(irow, 4).Value = Me.Class.Value
.Cells(irow, 5).Value = Me.Location.Value
.Cells(irow, 6).Value = Me.Attendance.Value
.Cells(irow, 8).Value = Me.Notes.Value
For I = 0 To Presenters.ListCount - 1
If Presenters.Selected(I) Then
ReDim Preserve arrValues(X)
arrValues(X) = Presenters.List(I)
X = X + 1
Presenters.Selected(I) = False
End If
Next I
With ws
.Range("c" & irow).Value = Join(arrValues, ",")
For I = 0 To Items.ListCount - 1
If Items.Selected(I) Then
ReDim Preserve arrValues(y)
arrValues(y) = Items.List(I)
y = y + 1
Items.Selected(I) = False
End If
Next I
With ws
.Range("G" & irow).Value = Join(arrValues, ",")
End If
Next I
End With
TypePresEvent.Value = ""
Topic.Value = ""
Class.Value = ""
Location.Value = ""
Attendance.Value = ""
Notes.Value = ""
End If
End Sub