Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
Lisa J
 
Posts: n/a
Default How to avoid duplicates across multiple worsheets in excel?

Ho do I avoid making duplicate entries across a number of worksheets in the
same spreadsheet? I can avoid duplicates on the same page by using the Data
Validation function, but when I try to do this across more than one sheet I
am not able to.

Any help would be much appreciated.


  #2   Report Post  
Posted to microsoft.public.excel.misc
mrice
 
Posts: n/a
Default How to avoid duplicates across multiple worsheets in excel?


You can use the following macro linked to the Workbook_SheetChange event
on the ThisWorkbook tab.

It's a bit slow and can be improved by restricting the search range to
the cells that you are likely to use.

e.g. Sheet.Range(Sheet.Cells(1, 1), Sheet.Cells(100, 100)) instead of
Sheet.Cells



Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As
Range)
Dim DuplicatedValue As Boolean
DuplicatedValue = False
For Each Sheet In Sheets
If Sheet Is Sh Then
If Application.CountIf(Sheet.Cells, Target) 1 Then
DuplicatedValue = True
End If
Else
If Application.CountIf(Sheet.Cells, Target) 0 Then
DuplicatedValue = True
End If
End If
Next Sheet
If DuplicatedValue = True Then MsgBox "Duplicate"

End Sub


--
mrice

Research Scientist with many years of spreadsheet development experience
------------------------------------------------------------------------
mrice's Profile: http://www.excelforum.com/member.php...o&userid=10931
View this thread: http://www.excelforum.com/showthread...hreadid=544326

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
Multiple instances of Excel Carol Crowley Excel Discussion (Misc queries) 9 March 17th 06 06:18 PM
how to copy multiple Excel files from Outlook into Excel??? Brainless_in_Boston Excel Discussion (Misc queries) 0 February 24th 06 03:46 PM
Can I embed or link multiple .pdf files into or to an excel file? GrubbyG Excel Discussion (Misc queries) 1 October 3rd 05 08:40 PM
Excel gets subtotals out of order using multiple sorts and subtot. jeffl Excel Discussion (Misc queries) 1 March 29th 05 01:35 AM
opening multiple instances of excel John B Excel Discussion (Misc queries) 4 January 28th 05 11:31 PM


All times are GMT +1. The time now is 09:48 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"