Restrict user to update duplicate value

Davesh Garg

Board Regular
Joined
Jun 3, 2014
Messages
59
I have been struck in using multiple VBA coding, however not getting what I require. Hope someone will assist me in resolving my issue.

There are certain entries that user is going to enter in excel in Column A, Column B, Column C, Column D and Column E. I require that user can update any value in Column A, Column B, Column C, Column D but as soon as, user is updating duplicate value of concatenate of all columns then user will get some message and cell value of last column E will delete. There are chances that user can copy and paste values from previous row, then also they’ll get an error message and they will not be able to copy that duplicate entry. However, if entries of concatenate all values in a row is unique, then user is able to paste it.

Below is a description with example and detail of my requirement:
Column AColumn BColumn CColumn DColumn EConcatenateRequirement
Row 1X1X2X3X4X5X1X2X3X4X5No issues, as it’s a unique value
Row 2X1X2X3X4X6X1X2X3X4X6No issues, as it’s a unique value
Row 3X1X2X3X4X6X1X2X3X4X6User should get error message, and value (X6) in Column E, Row 3 should be deleted
Row 4X2X1X3X4X5X2X1X3X4X5No issues, as it’s a unique value
Row 5
(copy and paste from Row 4)
X2X1X3X4X5X2X1X3X4X5User should get error message, and value (X5) in Column E, Row 5 should be deleted

I really had an issue from last one week to resolve this issue at the earliest, but is not able to resolve. Please help me out on this. Please let me know if any additional information is required. I am really thankful for your assistance.

Thanks - Dave
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hi, do you actually want to use VBA? Simplest way would be to count the number of times the value has appeared already, and then have a message or conditional formatting to highlight the problem.

i.e. in cell H1:
=COUNTIF(F$1:F1,F1)

and copy down. Anything returning a value >1 highlights a problem.
 
Upvote 0
You can also use Data Validation:

With the formula above in column H, you can add Data Validation to the columns A:E, like:

Data>DataValidation
Allow: Custom
Formula: $H7=1

This means when you enter a value which causes the COUNTIF function in column H to return a value >1, you get a validation message (which you can tailor)
 
Upvote 0
Rub this code to find the duplicates.

VBA Code:
Sub FindDups()
    Dim Sh As Worksheet
    Dim LstRw As Long, Rng As Range, c
    Set Sh = ActiveSheet

    With Sh
        LstRw = .Cells(.Rows.Count, "F").End(xlUp).Row
        For c = 2 To LstRw
            Set Rng = .Range("F2:F" & c)
            If Application.WorksheetFunction.CountIf(Rng, .Cells(c, "F")) > 1 Then
                .Cells(c, "E").ClearContents
            End If
        Next
    End With
End Sub
 
Upvote 0
Thanks Yard and Dave for your help.
Yard - Data validation will not work in case of copy and paste a row to different row.

Dave - I need to auto restrict a user, and above vba code will not work automatically. Additionally, user will not concatenate cells. This I told for reference whether there will be any duplicate entry or not after concatenate all columns and back-end will restrict user to update cell and will delete last value entered by user.

Really appreciate your assistance and response. Please assist on my requirement. Thanks
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,243
Members
449,075
Latest member
staticfluids

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