overriding incorrect data in excel with userforms

Logistix

Board Regular
Joined
Aug 23, 2006
Messages
77
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
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Hi

I'm guessing that ReEnterDetailsInt is a global variable that is set somehow by the ConfirmDataForm. Is this correct, and how is it set???

If it is not being reset, and is not global, the the default value will be 0 each time the sub is run so will add a new record....

Tony
 
Upvote 0

Forum statistics

Threads
1,214,520
Messages
6,120,007
Members
448,935
Latest member
ijat

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top