PDA

View Full Version : Eliminate unwanted data...



hkteo80
04-01-2011, 09:59 PM
Hello guys,

I try to write a vba code to eliminate data like this below

My input data:

Ht1.600//cannot be remove
.... //some other data
Ht1.600
......//some other data
Ht1.600
.....//some other data
Ht1.600
....//some other data
Ht1.500//cannot be remove
....//some other data
......//some other data
Ht1.500
....//some other data
Ht1.500

My output data:
Ht1.600
......//other data
.....
......
.....
Ht1.500
.....// other data
......
....
.....

what can i do to eliminate these extra "Ht" data similar value to the first one e.g. Ht 1.600 and Ht1.600 the second value will be delete, whereas Ht1.600 and Ht1.500 none of the value will be deleted?? The output is the value i want it to be.. Can anyone please help me with this one. Thank you

mdmackillop
04-02-2011, 02:43 AM
Welcome to VBAX
Give this a try. BTW You can post a sample workbook using Manage Attachments in the Go Advanced reply section

Option Explicit
Sub DelDuplicates()
Dim Lrw As Long, i As Long
Lrw = Cells(Rows.Count, 1).End(xlUp).Row
For i = Lrw To 2 Step -1
If Application.CountIf(Range(Cells(1, 1), Cells(i - 1, 1)), Cells(i, 1)) > 0 Then
Cells(i, 1).Clear
End If
Next
End Sub