特定の列のデータを特定番目から始まる文字列をキーにソートする
 サンプルマクロは、タイトル行のあるA列のデータを4文字目以降の
文字列をキーにソートします。

Sub Sample()

    Dim myStart As Integer
    Dim myCell As Range
    
    myStart = 4
    
    Application.ScreenUpdating = False
    
    Columns(1).Insert
    For Each myCell In _
        Range(Range("B2"), Cells(Rows.Count, 2).End(xlUp))
        With myCell
            .Offset(, -1).Value = Mid(.Value, myStart)
        End With
    Next
    Cells.Sort Range("A1"), xlAscending, header:=xlYes
    Columns(1).Delete
    
    Application.ScreenUpdating = True

End Sub

Excel95/97/2000



戻る


Excel Word Access VBA! モーグ