Home

remove duplicats

Deleted
Not applicable

can somone help me wth a formula or vba code to remove duplicats from a row wile entering data without any popup messages i am trying to work on a excel program that will identify pepole with a barcode and i dont want anyone shuld be able to scan the bar code 2 or more times

5 Replies

Hi,

 

I don't believe that this task can be done using a formula!

You definitely need to VBA code associated with an event to do so.

 

So, I would suggest this one:

Private Sub Worksheet_Change(ByVal Target As Range)
    
    On Error Resume Next
    Application.EnableEvents = False
    
    If Not Intersect(Target, Range("A:A")) Is Nothing Then
        Range("A:A").RemoveDuplicates Columns:=1, Header:=xlYes
    End If
    
    On Error GoTo 0
    Application.EnableEvents = True
    
End Sub

 

Please find it in the attached file.

Try to enter a duplicate barcode and see how it will be gone immediately.

And, please note that this code is only applied to column A, but you can modify it as you want.

 

Hope that helps

Highlighted

thank you this works good, but will this work on google sheets too?

Unfortunately, VBA isn't supported in Google Sheets or Excel Online.

but there is a option for script editor in google sheets, can someone help me with a code for google sheets?

I recommend you to ask the Stack Overflow community or to find a community that is dedicated to Google Sheets.

 

Regards

Related Conversations
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies
Early preview of Microsoft Edge group policies
Sean Lyndersay in Discussions on
65 Replies
*Updated 9/3* Syncing in Microsoft Edge Preview Channels
Elliot Kirk in Articles on
201 Replies
Tabs and Dark Mode
cjc2112 in Discussions on
2 Replies