I find a way and i record the macro that i need.
In second line im trying to add "ActiveSheet Unprotect ="my password"" and in the end to protect again, but i take a message for word "hidden". It doesnt complete the macro. What im doing wrong?
Sub SetSordingOrders()
Application.ScreenUpdating = False
Range("C6:F6").Select
Selection.AutoFilter
Range("C6").Select
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Add Key:= _
Range("C7:C31"), SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder _
:= _
"my criteria" _
, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Add Key:= _
Range("D7:D31"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveWindow.SmallScroll Down:=-27
Range("C6:F6").Select
Selection.AutoFilter
ActiveWindow.SmallScroll Down:=21
Range("C32:F32").Select
Selection.AutoFilter
Range("C32").Select
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Add Key:= _
Range("C33:C75"), SortOn:=xlSortOnValues, Order:=xlAscending, CustomOrder _
:= _
"my criteria" _
, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort.SortFields.Add Key:= _
Range("D33:D75"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption _
:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").AutoFilter.Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("C32:F32").Select
Selection.AutoFilter
For Each cell In ActiveSheet.Range("D7:D31, D33:D75, D77")
If cell.Value = "" Then
cell.EntireRow.Hidden = True
Else: cell.EntireRow.Hidden = False
End If
Next
Range("C6").Select
Application.ScreenUpdating = True
End Sub
Bookmarks