Hi all
I have got a simple table in cells A1 to F1 and a form with 6 textboxes to enter data into this table
Can anyone tell me why i can not add data to the first blank row ie. A2 to F2
it goes straight in the 3rd row A3 to F3
The code i am using is :
Private Sub btnInsertNewRecord_Click()
Dim nextrow As Range
'set the next row in the database
Set nextrow = Sheet2.Cells(Rows.Count, 0).End(xlUp).Offset(1, 0)
'add value to the next row in the database
nextrow = Textbox1.Value
nextrow.Offset(0, 1) = Textbox2.Value
nextrow.Offset(0, 2) = Textbox3.Value
nextrow.Offset(0, 3) = Textbox4.Value
nextrow.Offset(0, 4) = Textbox5.Value
nextrow.Offset(0, 5) = Textbox6.Value
Dim strRowSource As String
With [frmRecords].lstLookup
strRowSource = .RowSource
.RowSource = vbNullString
'Set back so it updates, use a new RowSource
.RowSource = strRowSource
End With
frmAddrecord.Hide
End Sub
I am using excel 2007 if this helps.
Many thanks.
Bookmarks