Hi,
I have a problem:
I am trying to run my userform that adds user input into an excel spreadsheet. The way it works is after the user enters their selection (via combobox) a summary form pops up and asks "to confirm whether the data entered is correct?".
My problem is that I cannot override the existing data in my excel file, instead it creates a new record on a new row. Does anyone have an idea how to do this?
My code at the moment looks like:
Private Sub NextForm_Click() ' Nextform being the Next button on the input screen
EnterHours.Hide
ConfirmDataForm.Show
If ReEnterDetailsInt = 0 Then
Worksheets("Records").Range("Start").End(xlDown).Select
With Selection
RefNumInt = .Offset(0, 0) + 1
.Offset(1, 0) = RefNumInt
.Offset(1, 1) = EmployeeNameBox
.Offset(1, 2) = DTPicker1
.Offset(1, 3) = HoursDepositBox
End With
ReEnterDetailsInt = ReEnterDetailsInt + 1
Else
With Selection
.Offset(0, 0) = RefNumInt
.Offset(0, 1) = EmployeeNameBox
.Offset(0, 2) = DTPicker1
.Offset(0, 3) = HoursDepositBox
End With
End If
End Sub
' ReEnterDetailsInt is a count that I am trying to use to determine whether the record is new or not?
Any obvious errors? Any help would be much appreciated. Thanks
I have a problem:
I am trying to run my userform that adds user input into an excel spreadsheet. The way it works is after the user enters their selection (via combobox) a summary form pops up and asks "to confirm whether the data entered is correct?".
My problem is that I cannot override the existing data in my excel file, instead it creates a new record on a new row. Does anyone have an idea how to do this?
My code at the moment looks like:
Private Sub NextForm_Click() ' Nextform being the Next button on the input screen
EnterHours.Hide
ConfirmDataForm.Show
If ReEnterDetailsInt = 0 Then
Worksheets("Records").Range("Start").End(xlDown).Select
With Selection
RefNumInt = .Offset(0, 0) + 1
.Offset(1, 0) = RefNumInt
.Offset(1, 1) = EmployeeNameBox
.Offset(1, 2) = DTPicker1
.Offset(1, 3) = HoursDepositBox
End With
ReEnterDetailsInt = ReEnterDetailsInt + 1
Else
With Selection
.Offset(0, 0) = RefNumInt
.Offset(0, 1) = EmployeeNameBox
.Offset(0, 2) = DTPicker1
.Offset(0, 3) = HoursDepositBox
End With
End If
End Sub
' ReEnterDetailsInt is a count that I am trying to use to determine whether the record is new or not?
Any obvious errors? Any help would be much appreciated. Thanks