How To Prevent Duplicate URL Entries in the Cell in a Column?

kalucharan

New Member
Joined
Mar 23, 2014
Messages
8
Office Version
  1. 2016
Platform
  1. Windows
Dear Experts,

I tried to solve above problem using Data Validation formula but it does not help as per my wish. Because data validation does not work if somebody copy paste the duplicate values,it works when somebody types duplicate values in next column. So if I want to enter lot of urls to a column then it is completely impossible to type so must have to copy paste from the browser. I have created a sample sheet and kindly requested you all to solve this problem either using formula or using Data validation in sample 1 and sample 2 respectively.

Using Any Formula to do this
URLCheck
https://www.google.com/

<tbody>
</tbody>
1
https://www.facebook.com/

<tbody>
</tbody>
1
http://www.mrexcel.com/forum/search.php?searchid=9709271
http://www.mrexcel.com/forum/search.php?searchid=9709272
https://www.google.com/2

<tbody>
</tbody>

Using data validation if it is possible
https://www.google.com/
https://www.facebook.com/
http://www.mrexcel.com/forum/search.php?searchid=970927
http://www.mrexcel.com/forum/search.php?searchid=970927
https://www.google.com/

<tbody>
</tbody>

Thanking you for your help in advance.

Regards
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Welcome to the MrExcel board!

To do that, you would need to use vba code. However, the user would have to have macros enabled. If macros are not enabled, then the vba method is also defeated.

So there isn't a perfect answer to this but post back if you want a suggestion for the macro approach.
 
Upvote 0
Welcome to the MrExcel board!

To do that, you would need to use vba code. However, the user would have to have macros enabled. If macros are not enabled, then the vba method is also defeated.

So there isn't a perfect answer to this but post back if you want a suggestion for the macro approach.

Thank you for the reply.
Could you please suggest if you can do it using macro.
 
Upvote 0
Test in a copy of your workbook

To implement ..

1. Right click the sheet name tab and choose "View Code".

2. Copy and Paste the code below into the main right hand pane that opens at step 1.

3. Close the Visual Basic window & test.

4. If using Excel 2007 or later your workbook will need to be saved as a macro-enabled file (*.xlsm)

Rich (BB code):
Private Sub Worksheet_Change(ByVal Target As Range)
  Dim Changed As Range, c As Range
  Dim sDel As String
  
  Const ColOfInterest As String = "A" '<-Column where you want to prevent duplicates
  
  Set Changed = Intersect(Columns(ColOfInterest), Target)
  If Not Changed Is Nothing Then
    Application.EnableEvents = False
    For Each c In Changed
      If WorksheetFunction.CountIf(Columns(ColOfInterest), c.Value) > 1 Then
        sDel = sDel & vbLf & c.Value
        c.ClearContents
      End If
    Next c
    Application.EnableEvents = True
    If Len(sDel) Then
      MsgBox "Duplicate values entered have been removed:" & sDel
    End If
  End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,641
Messages
6,120,694
Members
448,979
Latest member
DET4492

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