Sam Clough
New Member
- Joined
- Feb 9, 2014
- Messages
- 44
- Office Version
- 365
- Platform
- Windows
I have a large (10MB) file for rankings of sport on Excel 2016. It has a "button" for various sortings. Out of the blue when using this button I get Run-time error '1004' To do this, all the merged cells need to be the same size. As I am not good on these macros, I need urgent help. Can I upload the file for someone to maybe assist. I am desperate.
You need to start your own thread and maybe somebody will pick up on it. This thread deals with a different issue. The 1004 error code can be for various causes, usually related to user coding error like misspelled words, erroneous syntax, etc.
This is what Debug shows:
ActiveSheet.Unprotect
Range("A7:AZZ3050").Sort _
Key1:=Range("A7"), Order1:=xlDescending, _
Key2:=Range("F7"), Order2:=xlDescending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
End Sub
Private Sub CommandButton3_Click()
'sort male state
ActiveSheet.Unprotect
Range("A7:AZZ3050").Sort _
Key1:=Range("A7"), Order1:=xlDescending, _
Key2:=Range("E7"), Order2:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
End Sub
Private Sub CommandButton4_Click()
'sort female name
ActiveSheet.Unprotect
Range("A7:AZZ3050").Sort _
Key1:=Range("A7"), Order1:=xlAscending, _
Key2:=Range("C7"), Order2:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
End Sub
Private Sub CommandButton5_Click()
'sort female points
ActiveSheet.Unprotect
Range("A7:AZZ3050").Sort _
Key1:=Range("A7"), Order1:=xlAscending, _
Key2:=Range("F7"), Order2:=xlDescending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
End Sub
Private Sub CommandButton6_Click()
'sort female state
ActiveSheet.Unprotect
Range("A7:AZZ3050").Sort _
Key1:=Range("A7"), Order1:=xlAscending, _
Key2:=Range("E7"), Order2:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
End Sub
Private Sub CommandButton7_Click()
'sort overall points
ActiveSheet.Unprotect
Range("A7:AZZ3050").Sort _
Key1:=Range("F7"), Order1:=xlDescending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
End Sub
Private Sub CommandButton8_Click()
'sort overall names
ActiveSheet.Unprotect
Range("A7:AZZ3050").Sort _
Key1:=Range("C7"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
End Sub
Private Sub CommandButton9_Click()
'sort overall state
ActiveSheet.Unprotect
Range("A7:AZZ3050").Sort _
Key1:=Range("E7"), Order1:=xlAscending, _
Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, DataOption2 _
:=xlSortNormal
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
ActiveSheet.EnableSelection = xlUnlockedCells
End Sub