Option Explicit
Sub Macro1()
'
' Macro1 Macro
'
'
ActiveWorkbook.Worksheets("Plan1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Plan1").Sort.SortFields.Add Key:=Range("D4:D17"), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Plan1").Sort.SortFields.Add Key:=Range("E4:E17"), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Plan1").Sort.SortFields.Add Key:=Range("F4:F17"), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Plan1").Sort.SortFields.Add Key:=Range("G4:G17"), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Plan1").Sort.SortFields.Add Key:=Range("H4:H17"), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Plan1").Sort.SortFields.Add Key:=Range("I4:I17"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Plan1").Sort.SortFields.Add Key:=Range("C4:C17"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Plan1").Sort
.SetRange Range("B3:I17")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Quando não sei fazer algo no VBA, vou ao menu EXIBIÇÃO >> MACROS >> GRAVAR MACRO
Faço o que eu quero aí volto ao menu EXIBIÇÃO >> MACROS >> PARAR GRAVAÇÃO
Aperto Alt + F11 e vejo como a macro fez aquilo. Tento entender e tento adaptar.
Postado : 02/04/2018 11:28 am