Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default search range for duplicates

I have 5 ranges (columns) Mon Tue Wed etc. I enter names
in each range. As each name is entered I would like to
search the names already entered above it and check for
duplicates, then have a message box "Name already used"
It's OK if I duplicate names from Mon to Tue so I want to
check each day separately. Any ideas? Thanks!!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 218
Default search range for duplicates

Paste the following to the sheet code module:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range
With Target
Set Rng = Columns(.Column)
If .Count = 1 Then
If Application.CountIf(Rng, .Value) 1 Then
..Select
..Interior.ColorIndex = 6
MsgBox "Name already exists"
..Interior.ColorIndex = xlNone
End If
End If
End With
End Sub

Regards,
Greg
-----Original Message-----
I have 5 ranges (columns) Mon Tue Wed etc. I enter names
in each range. As each name is entered I would like to
search the names already entered above it and check for
duplicates, then have a message box "Name already used"
It's OK if I duplicate names from Mon to Tue so I want to
check each day separately. Any ideas? Thanks!!
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 218
Default search range for duplicates

You can remove the "If .Count = 1" line and one of
the "End If lines near the end.

Regards,
Greg


-----Original Message-----
Paste the following to the sheet code module:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range
With Target
Set Rng = Columns(.Column)
If .Count = 1 Then
If Application.CountIf(Rng, .Value) 1 Then
..Select
..Interior.ColorIndex = 6
MsgBox "Name already exists"
..Interior.ColorIndex = xlNone
End If
End If
End With
End Sub

Regards,
Greg
-----Original Message-----
I have 5 ranges (columns) Mon Tue Wed etc. I enter

names
in each range. As each name is entered I would like to
search the names already entered above it and check for
duplicates, then have a message box "Name already used"
It's OK if I duplicate names from Mon to Tue so I want

to
check each day separately. Any ideas? Thanks!!
.

.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default search range for duplicates

Doug,

Try the FIND METHOD. Here's a description from VBA HELP:
-----------
Find Method

Finds specific information in a range, and returns a Range object that
represents the first cell where that information is found. Returns Nothing
if no match is found. Doesn't affect the selection or the active cell.
For information about using the Find worksheet function in Visual Basic, see
Using Worksheet Functions in Visual Basic.
Syntax
expression.Find(What, After, LookIn, LookAt, SearchOrder, SearchDirection,
MatchCase, MatchByte)

TH

On 4/15/04 18:33, in article , "Doug
Loewen" wrote:

I have 5 ranges (columns) Mon Tue Wed etc. I enter names
in each range. As each name is entered I would like to
search the names already entered above it and check for
duplicates, then have a message box "Name already used"
It's OK if I duplicate names from Mon to Tue so I want to
check each day separately. Any ideas? Thanks!!


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
Look for duplicates within a range Access Joe Excel Worksheet Functions 5 August 1st 08 09:18 PM
Search for duplicates across three worksheets Sarah_Lund Excel Worksheet Functions 1 May 20th 08 12:29 AM
create a macro to search an excel spread for duplicates jamalin Excel Worksheet Functions 4 February 16th 07 10:58 AM
how do I search a colum for duplicates automatically Andrew Excel Discussion (Misc queries) 2 February 8th 06 02:45 PM
Word Search from Excel results in Duplicates Sarvesh Excel Programming 2 December 23rd 03 05:23 PM


All times are GMT +1. The time now is 10:13 PM.

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"