好吧,这听起来像一个有趣的任务,所以我尝试Vityata的方法与另一个工作表中的不同列表。
Sub crazySort()
Dim ws As Worksheet
Dim ws2 As Worksheet
Dim lastRow As Long
Dim yourcolumnindex, letters, numbers, others As Long
Dim i As Long
Set ws = Worksheets("sheet")
'This is the sheet for our temp lists, rename accordingly
Set ws2 = Worksheets("tempsheet")
columnsCount = x
i = 1
letters = 1
others = 1
numbers = 1
With ws
For j = 1 to columnsCount
'loop through all the cells in your column
'change yourcolumnindex accordingly
Do While .Cells(i, j) <> ""
'check for the ASCII-code of the first character in every list
Select Case Asc(Left(.Cells(i, j), 1))
Case 65 To 90, 97 To 122
'if it's a letter, put it in column 1
ws2.Cells(letters, 1) = .Cells(i, j)
letters = letters + 1
Case 48 To 57
'if it's a cipher, put it in column 2
ws2.Cells(numbers, 2) = .Cells(i, j)
numbers = numbers + 1
Case Else
'is it something else, put it in column 3
ws2.Cells(others, 3) = .Cells(i, j)
others = others + 1
End Select
i = i + 1
Loop
Next
End With
End Sub
这部分只包含分割列表,但从这里开始它只是排序和复制/粘贴回来。
玩得开心。
逐个读取范围。根据它们的内容将单元格放入不同的列表(或数组)中。你会有3个列表(或数组)。然后对列表(或数组)进行排序。然后逐一打印。瞧! :) – Vityata
谢谢!是的,现在我必须找到排序表的代码,而不仅仅是列内容 – cody