ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Domain Name Sorting in Excel (https://www.excelbanter.com/excel-programming/368749-domain-name-sorting-excel.html)

datarancher

Domain Name Sorting in Excel
 
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!


Tom Ogilvy

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!





All times are GMT +1. The time now is 01:44 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com