Consulting

Results 1 to 2 of 2

Thread: Solved: using countif in code

  1. #1
    VBAX Tutor
    Joined
    Nov 2007
    Posts
    291
    Location

    Solved: using countif in code

    Hello,

    I am trying to loop through a list of cells to see if there are duplicates and an using :-

    [VBA]
    Sub test()
    Dim i As Integer
    With ActiveSheet
    For i = 1 To 10
    If WorksheetFunction.CountIf(.Columns("A:A"), .Cells(i, 1)) > 1 Then
    .Cells(i, 1).ColorIndex = 6
    .Cells(i, 1).Pattern = xlSolid
    End If
    Next i
    End With
    End Sub
    [/VBA]

    Can anyone see my error?

  2. #2
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    [VBA] .Cells(i, 1).Interior.ColorIndex = 6[/VBA]
    should work.
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

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