Hi,
I have a spreadsheet with a custom data entry form to control input of forecast numbers. When a user hits the 'add' button on the form, the data from the form is added to the bottom of the worksheet 'fdata'.
What I need to do when adding the data to the form, is check for previous duplicate entries with matching data in columns B, C, J and K and containing "TRUE" in Column F, if a duplicate is found I need to change 'TRUE' to 'FALSE' in column F.
My code looks like this so far, so I need to add this check/change at the end:-
Private Sub Add1_Click()
Dim lRow As Long
Dim lIntModel As Long
Dim ws As Worksheet
Set ws = Worksheets("FData")
lRow = ws.Cells.Find(What:="*", SearchOrder:=xlRows, _
SearchDirection:=xlPrevious, LookIn:=xlValues).Row + 1
'copy the data to the database
With ws
.Cells(lRow, 1).Value = Me.cboMod1.Value
.Cells(lRow, 2).Value = Me.cboYear.Value
.Cells(lRow, 3).Value = Me.cboMonth.Value
.Cells(lRow, 4).Value = Me.cboFor1.Value
.Cells(lRow, 5).Value = Now()
.Cells(lRow, 6).Value = "TRUE"
.Cells(lRow, 7).Value = Me.cboAuthor.Value
.Cells(lRow, 8).Value = Me.cboReason.Value
.Cells(lRow, 9).Value = Me.cboCategory.Value
.Cells(lRow, 11).Value = Me.cboSen1
.Cells(lRow, 13).Value = Now()
End With
MsgBox "Model Forecast has been added"
End Sub
Can anyone help me with some code to do this.
Spreadsheet attached.
Thanks,
Louise
Bookmarks