OK i have my userform to input data on my work sheet, now i wish to enable the same form to have ability to update on previous information. i.e. i enter data in user form with account number, name etc, i want to be able to load the userform and type in a account number i already have inputted on the sheet and for it to pull all of the information into the userform and allow me to complete text boxes i missed last time and then press save to save it in the same place. here is the userform code i am using.
Private Sub UserForm_Click()
Dim rng As Range
Dim LastRow As Long
If datebox.Text = " " Then
MsgBox "You Must Enter A Date."
datebox.SetFocus
Exit Sub
End If
LastRow = Worksheets("Main Data").Range("a65536").End(xlUp).Row
Set rng = Worksheets("Main Data").Range("a" & (LastRow + 1))
With rng
.Offset(0, 0).Value = datebox.Text
.Offset(0, 1).Value = txtcode.Text
.Offset(0, 2).Value = txtacnumber.Text
.Offset(0, 3).Value = Txtpersonnumber.Text
.Offset(0, 5).Value = txtsuccess.Text
.Offset(0, 6).Value = txtcost.Value
.Offset(0, 7).Value = txtmade.Value
.Offset(0, 8).Value = txtgross.Value
.Offset(0, 9).Value = txtcompleted.Text
End With
Unload frmUserForm1
End Sub
Private Sub UserForm_Click()
Dim rng As Range
Dim LastRow As Long
If datebox.Text = " " Then
MsgBox "You Must Enter A Date."
datebox.SetFocus
Exit Sub
End If
LastRow = Worksheets("Main Data").Range("a65536").End(xlUp).Row
Set rng = Worksheets("Main Data").Range("a" & (LastRow + 1))
With rng
.Offset(0, 0).Value = datebox.Text
.Offset(0, 1).Value = txtcode.Text
.Offset(0, 2).Value = txtacnumber.Text
.Offset(0, 3).Value = Txtpersonnumber.Text
.Offset(0, 5).Value = txtsuccess.Text
.Offset(0, 6).Value = txtcost.Value
.Offset(0, 7).Value = txtmade.Value
.Offset(0, 8).Value = txtgross.Value
.Offset(0, 9).Value = txtcompleted.Text
End With
Unload frmUserForm1
End Sub