Hi guys,
I have this code to use with a form and add lines in range A12:J25 Sheet1, problem is that it is giving me an error in the section highlighted in red. The problem is that I need the information from the form to be populated in rows 12 thru 25, each time I add data, it needs to find the first empty row beetween 11 and 25 and place the data there without over writing the prior data. Can anyone help me?
Private Sub cmdAdd_Click()
Dim iRow As Long
Dim ws As Range
Set ws = Range("A12")
'find first empty row in database
iRow = ws.Cells(Rows.Count, 1) _
.End(xlUp).Offset(1, 0).Row
'copy the data to the database
ws.Cells(iRow, 1).Value = Me.ComboBox1.Value
ws.Cells(iRow, 2).Value = Me.ComboBox2.Value
ws.Cells(iRow, 6).Value = Me.TextBox3.Value
ws.Cells(iRow, 7).Value = Me.TextBox1.Value
ws.Cells(iRow, 8).Value = Me.TextBox2.Value
'clear the data
Me.ComboBox1.Value = ""
Me.ComboBox2.Value = ""
Me.TextBox3.Value = ""
Me.TextBox1.Value = ""
Me.TextBox2.Value = ""
Me.ComboBox2.SetFocus
End Sub
Bookmarks