2012-12-20 2 views
0

I 데이터를 N 열에있는 날짜별로 정렬하려면 각 행을 정렬하려고합니다. 지금은 다른 정보를 바꿔서 istelf만으로 n 열을 정렬하고 있습니다. 전체 행이 해당 행의 단일 셀과 반대 방향으로 이동하도록 코드를 다시 작성하려면 어떻게해야합니까? 날짜 열별로 정렬 vba

Sub SortByDate() Dim rSortRange As Range Dim ws As Worksheet Set ws = Sheets("Copy") Set rSortRange = ws.Range("N11", "N111") rSortRange.Sort Key1:=ws.Range("N11"), Order1:=xlAscending, _ Key2:=Range("N20"), Order2:=xlAscending, _ Key3:=Range("N29"), Order3:=xlAscending, _ Header:=xlNo, OrderCustom:=1, MatchCase:=False, _ Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _ DataOption2:=xlSortNormal, DataOption3:=xlSortNormal End Sub 

때때로 나는 그냥 매크로를 기록하는 것이 얼마나 쉬운 잊지 다음 매크로 코드

Sub SortByDate() 
Dim rSortRange As Range 
Dim ws As Worksheet 

Set ws = Sheets("Copy") 
Set rSortRange = ws.Range("N11", "N111") 
rSortRange.Sort Key1:=ws.Range("N11"), Order1:=xlAscending, _ 
      Key2:=Range("N20"), Order2:=xlAscending, _ 
      Key3:=Range("N29"), Order3:=xlAscending, _ 
      Header:=xlNo, OrderCustom:=1, MatchCase:=False, _ 
      Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _ 
      DataOption2:=xlSortNormal, DataOption3:=xlSortNormal 
End Sub 

으로 뭔가를 얻었다!

+0

시트 조각을 보여주기가 너무 어렵습니까? 전체 데이터 범위를 가져온 다음 날짜 열을 정렬하여 정렬 할 수 있습니다. – bonCodigo

+1

매크로를 기록하십시오. 나는 당신에게 코드를 줄 수는 있지만 먼저 시도해 보길 원합니다;) –

+0

@David 답변을 답안으로 추가하십시오 ... –

답변

1
Sub SortByDate() 
    Dim rSortRange As Range 
    Dim ws As Worksheet 

    Set ws = Sheets("Copy") 
    Set rSortRange = ws.Range("N11", "N111") 
    rSortRange.Sort Key1:=ws.Range("N11"), Order1:=xlAscending, _ 
     Key2:=Range("N20"), Order2:=xlAscending, _ 
     Key3:=Range("N29"), Order3:=xlAscending, _ 
     Header:=xlNo, OrderCustom:=1, MatchCase:=False, _ 
     Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _ 
     DataOption2:=xlSortNormal, DataOption3:=xlSortNormal 
    End Sub