Results 1 to 4 of 4

Programatically look for duplicates and rename data in a column if one found

Threaded View

  1. #1
    Registered User
    Join Date
    04-20-2013
    Location
    sydney, australia
    MS-Off Ver
    Excel 2013
    Posts
    3

    Programatically look for duplicates and rename data in a column if one found

    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
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1