Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Preventing Duplicates using VBA (code)

I have a sheet that has 8 digit (111-1111) telephone
numbers in colume B. I need to programatically prevent
anyone from entering duplicate values. I can do it using
the Data - Valadation and the COUNTIF function, but that
leaves the validation runction open so others can change
or delete it. I really would rather do it in VBA.

Help.

Thanks to all...
Jerry McCutchen
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Preventing Duplicates using VBA (code)

Tony,

Thank you so much! This works as advertised!

Jerry
-----Original Message-----
Jerry

Put the following into a worksheet code area.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Not Intersect(Target, Range("B1").EntireColumn) Is
Nothing Then
If WorksheetFunction.CountIf(Range("B:B"), Target) 1
Then
MsgBox "Duplicate numbers not allowed"
Target.ClearContents
End If
End If

End Sub

Tony
-----Original Message-----
I have a sheet that has 8 digit (111-1111) telephone
numbers in colume B. I need to programatically prevent
anyone from entering duplicate values. I can do it

using
the Data - Valadation and the COUNTIF function, but that
leaves the validation runction open so others can change
or delete it. I really would rather do it in VBA.

Help.

Thanks to all...
Jerry McCutchen
.

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Preventing tofimoon3 via OfficeKB.com New Users to Excel 4 February 20th 09 06:03 PM
Preventing Duplicates Ed Excel Discussion (Misc queries) 11 June 1st 06 03:56 AM
zip code and +4 duplicates darkwood Excel Discussion (Misc queries) 3 April 7th 06 05:52 PM
Deleting ALL duplicates using Pearson's code [email protected] Excel Worksheet Functions 2 May 6th 05 01:50 PM
preventing duplicates Bonnie Excel Worksheet Functions 2 March 2nd 05 02:14 PM


All times are GMT +1. The time now is 11:18 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"