"select distinct" in Excel

G

Gusur

Dear All,
Is there any similar formula which works like "select distinct" syntax?
For example, I have random data

A
1 Apple
2 Orange
3 Apple
4 Mango
5 Orange

and the result should be

B
1 Apple
2 Mango
3 Orange

Thanks
 
C

chris

Place a control box on the sheet from the control box.
Double click the command button to open code window and paste
following codes

Code:
Private Sub CommandButton1_Click()
Dim row As Integer, col As Integer
row = 1
col = 1

While Sheet1.Cells(row, col).Value <> ""
delRereat Sheet1.Cells(row, col).Value, row
row = row + 1
Wend
End Sub

Private Sub delRereat(str As String, i As Integer)
Dim row As Integer, col As Integer
row = i + 1
col = 1

While Sheet1.Cells(row, col).Value <> ""
If Sheet1.Cells(row, col).Value = str Then
Sheet1.Rows(row).Delete
End If
row = row + 1
Wend

End Sub


Chris
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top