Consulting

Results 1 to 3 of 3

Thread: Compare and delele cells with equal value

  1. #1

    Compare and delele cells with equal value

    How I can delete all the cells with equal values?

    Example:

    A B C D E F G
    1 1 1 1 5 1 1

    The correct final result is: 5

    Tks.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Public Sub ProcessData()
    Dim i As Long
    Dim LastCol As Long
    Dim cell As Range
    Dim sh As Worksheet

    With Application

    .ScreenUpdating = False
    .Calculation = xlCalculationManual
    End With

    With ActiveSheet

    .Rows(2).Insert
    .Rows(1).Copy .Range("A2")
    LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column
    For i = LastCol To 1 Step -1

    If Application.CountIf(.Rows(1), .Cells(2, i).Value) > 1 Then

    .Cells(2, i).Delete shift:=xlShiftToLeft
    End If
    Next i
    .Rows(1).Delete

    End With

    With Application

    .Calculation = xlCalculationAutomatic
    .ScreenUpdating = True
    End With

    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    tanks xld, for your answer.

Posting Permissions

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