+ Reply to Thread
Results 1 to 4 of 4

Highlight duplicates

Hybrid View

  1. #1
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello SITCFanTN,

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

    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

  2. #2
    SITCFanTN
    Guest

    Re: 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
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1