LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 131
Default Marco Help

Hiya, (Sorry forgot to include example code).

I've been using this macro to check for duplicate entries in a colomn,

'Check for duplicate names
Sub HighlightDuplicates()
Dim Cell As Range
Dim Cell_Range As Range
Dim MyCollection As New Collection

n = 0
'Find last cell entry in the row
LastEntry = ActiveSheet.Cells(Rows.Count, "A").End(xlUp).Address
'Define the range to examine
Set Cell_Range =
ActiveSheet.Range("A5,A7,A9,A11,A13,A15,A17,A19,A2 1,A23,A25,A27,A29,A31,A33,A35,A37,A39,A41,A43,A45" )

For Each Cell In Cell_Range
On Error Resume Next
MyCollection.Add Item:="1", Key:=Cell.Text
If Err.Number = 457 Then
Cell.Interior.ColorIndex = 36
Err.Clear
n = n + 1
End If
Next Cell

If n 0 _
Then
If n = 1 _
Then
v = "is "
noun = " duplicate, Please Check Names."
Else:
v = "are "
noun = " duplicates, Please Check Names"
End If

MsgBox ("There " & v & n & noun)
Else:
MsgBox ("There are no duplicates.")
End If

End Sub


However, some cell are blank at the moment and the macro is counting them as
duplicate entries, is there a way that the macro can be modified so that
blank cells are ignored from the count.

Thanks to anyone who can help.

Respectx
Laddie.

 
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
Marco Puzzled Excel Discussion (Misc queries) 3 July 30th 07 05:09 PM
Marco Help looper Excel Discussion (Misc queries) 2 May 12th 07 06:55 PM
Help with marco Gary Keramidas Excel Programming 1 December 2nd 06 05:17 AM
marco help mr1104839 Excel Programming 2 August 17th 06 05:42 PM
help me with this marco Gary Keramidas Excel Programming 1 April 22nd 06 02:01 AM


All times are GMT +1. The time now is 11:44 PM.

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

About Us

"It's about Microsoft Excel"