好吧,這聽起來像一個有趣的任務,所以我嘗試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