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.
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.
[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
tanks xld, for your answer.