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

I've searched this site and see all kinds of posts to delete duplicates, but
nothing about highlighting them. I have a sheet with 1000 of rows and would
like VBA code to look in Column B titled "GID" and highlight or somehow spike
out duplicate numerical values. Any help you can give me is appreciated,
thank you.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Highlight duplicates


Hello SITCFanTN,

Add a VBA module to your Workbook and paste the macro code below int
it.


Code
-------------------

Sub HighlightDuplicates()

'Highlight duplicates in Yellow
Dim Cell As Range
Dim Cell_Range As Range
Dim MyCollection As New Collection

'Find last cell entry in the row
LastEntry = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Address
'Define the range to examine
Set Cell_Range = ActiveSheet.Range("B1", LastEntry)

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 = 6
Err.Clear
End If
Next Cell

End Sub

-------------------


Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=55716

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Highlight duplicates

Hi SITCFanTN,

This link has some useful information
http://www.cpearson.com/excel/duplicat.htm.
cheers
Odin
SITCFanTN wrote:
I've searched this site and see all kinds of posts to delete duplicates, but
nothing about highlighting them. I have a sheet with 1000 of rows and would
like VBA code to look in Column B titled "GID" and highlight or somehow spike
out duplicate numerical values. Any help you can give me is appreciated,
thank you.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Highlight duplicates

This worked great, thanks a bunch Leith!

"Leith Ross" wrote:


Hello SITCFanTN,

Add a VBA module to your Workbook and paste the macro code below into
it.


Code:
--------------------

Sub HighlightDuplicates()

'Highlight duplicates in Yellow
Dim Cell As Range
Dim Cell_Range As Range
Dim MyCollection As New Collection

'Find last cell entry in the row
LastEntry = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Address
'Define the range to examine
Set Cell_Range = ActiveSheet.Range("B1", LastEntry)

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 = 6
Err.Clear
End If
Next Cell

End Sub

--------------------


Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=557160


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Highlight duplicates

Is there any way to check and highlight the entire row rather than a column

I want to find out if any entries in my expense databse have been entered
twice, because the totals do not add up.

Dylan

"Leith Ross" wrote:


Hello SITCFanTN,

Add a VBA module to your Workbook and paste the macro code below into
it.


Code:
--------------------

Sub HighlightDuplicates()

'Highlight duplicates in Yellow
Dim Cell As Range
Dim Cell_Range As Range
Dim MyCollection As New Collection

'Find last cell entry in the row
LastEntry = ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Address
'Define the range to examine
Set Cell_Range = ActiveSheet.Range("B1", LastEntry)

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 = 6
Err.Clear
End If
Next Cell

End Sub

--------------------


Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=557160


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
How can I highlight duplicates from 2 rows using set criteria Sam.D Excel Discussion (Misc queries) 7 February 10th 10 01:36 PM
Highlight rows if duplicates are found Pierre Excel Worksheet Functions 3 January 21st 10 03:03 PM
Highlight Duplicates with different Color samangh1 via OfficeKB.com Excel Discussion (Misc queries) 0 January 22nd 09 08:28 PM
Highlight Duplicates, Macro? NPell Excel Worksheet Functions 6 April 9th 08 02:02 PM
How do i locate/highlight duplicates ? Lizardking Excel Discussion (Misc queries) 3 October 12th 06 04:36 PM


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