View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Domain Name Sorting in Excel

Assume the data you show starts in A1 of worksheet Data and you want to
write your new list to a sheet named Sheet1:

Sub efg()
Dim rng As Range, cell As Range
Dim iloc As Long, ext As String
Dim icol As Long, v As Variant
v = Array("com", "net", "org")
With Worksheets("Data")
Set rng = .Range(.Cells(1, 1), .Cells(1, 1).End(xlDown))
End With
Worksheets("Sheet1").Range("A1:C1").Value = v
For Each cell In rng
iloc = InStr(1, cell, ".", vbTextCompare)
If iloc < 0 Then
ext = LCase(Right(cell, Len(cell) - iloc))
Select Case ext
Case "com"
icol = 1
Case "net"
icol = 2
Case "org"
icol = 3
End Select
With Worksheets("Sheet1")
rw = .Cells(Rows.Count, icol).End(xlUp).Row + 1
.Cells(rw, icol).Value = cell.Value
End With
End If
Next

End Sub


--
Regards,
Tom Ogilvy


"datarancher" wrote in message
ups.com...
I was wonderig if there would be an easy way to take a group of domain
names as such:

aaa.com
bbb.com
ccc.com
aaa.net
bbb.net
ccc.net
aaa.org
bbb.org
ccc.org

then be able to create a worksheet that would but just list the .com
names in colum A, the .net names in column B, the .org names in column
C with a header for each column.

.com .net .org

Thank you in advance!