Domain Name Sorting in Excel

  • Thread starter Thread starter datarancher
  • Start date Start date
D

datarancher

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!
 
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
 

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

Back
Top