使用子sorting在Excel中,sorting不正确

我想sorting我的工作表中的具有我的testing用例ID的特定列,我目前的sorting子(下面给出)sorting它像

1.1.1 1.1.12 1.1.15 1.1.2 1.1.22 1.1.3 

是因为它把它作为字母数字数据吗?

如何让它正确sorting?

 1.1.1 1.1.2 1.1.3 1.1.12 1.1.15 1.1.22 

我的子function:

  Function sortSheet(ByVal sheet As Excel.Worksheet) Dim oneRange As Range Dim aCell As Range Dim lastRow As Long, lastCol As Integer 'Calculating the last row and column lastRow = sheet.Cells(Rows.Count, 1).End(xlUp).row lastCol = sheet.Cells(1, Columns.Count).End(xlToLeft).Column 'Setting the range in which sorting is to be done Set oneRange = sheet.Range(sheet.Cells(2, 1), sheet.Cells(lastRow, lastCol)) 'Setting the range according to which it will be sorted Set aCell = sheet.Range("A2") 'Sorting oneRange.Sort Key1:=aCell, Order1:=xlAscending, Header:=xlGuess End Function 

在帮手列中的正确公式将使这个快速的工作。

使用助手列进行排序

B2中的公式是,

 =TEXT(LEFT(A2, FIND(".", A2)-1), "000")&TEXT(MID(A2, FIND(".", A2)+1, 9), "000")&TEXT(MID(A2, FIND(".", A2, FIND(".", A2)+1)+1, 9), "000") 

根据需要填写。 这是有效的,因为对于多级序号有一个“块”的静态数量。 如果必须容纳1,2或3个部分,公式将会更加复杂。