Results 1 to 7 of 7

Thread: VBA Code To Highlight Duplicate Values In A Column

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    5
    Rep Power
    0

    VBA Code To Highlight Duplicate Values In A Column

    Hello,

    My current vba code is finding the duplicate strings however only if they are in a sequence which is one after another. If it is out of sequence it does not work. So if the word Walter is repeated one after another it works. However if you put John in between it does not work. Please see the below code I have:

    Code:
    Sub FindDups ()
       
       ScreenUpdating = False
       FirstItem = ActiveCell.Value
       SecondItem = ActiveCell.Offset(1, 0).Value
       Offsetcount = 1
       Do While ActiveCell <> ""
          If FirstItem = SecondItem Then
            ActiveCell.Offset(Offsetcount,0).Interior.Color = RGB(255,0,0)
            Offsetcount = Offsetcount + 1
            SecondItem = ActiveCell.Offset(Offsetcount, 0).Value
          Else
            ActiveCell.Offset(Offsetcount, 0).Select
            FirstItem = ActiveCell.Value
            SecondItem = ActiveCell.Offset(1,0).Value
            Offsetcount = 1
          End If
       Loop
       ScreenUpdating = True
    End Sub
    Last edited by Excel Fox; 05-15-2013 at 08:59 AM. Reason: Code Tags Added

Similar Threads

  1. Replies: 4
    Last Post: 06-01-2013, 01:08 PM
  2. Replies: 10
    Last Post: 05-23-2013, 12:30 PM
  3. Replies: 17
    Last Post: 05-22-2013, 11:58 PM
  4. Highlight Active Cell’s Row and Column
    By Transformer in forum Tips, Tricks & Downloads (No Questions)
    Replies: 0
    Last Post: 05-17-2013, 12:32 AM
  5. Replies: 7
    Last Post: 04-22-2013, 01:41 PM

Posting Permissions

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