Hi
I am still very new to macros and most of what I have done I have managed to find from the internet and then make a few changes to suit what I am looking for. This time around though I don't know what I have done wrong and why it is not working.
I want to sort my spreadsheet by Column A and then Column B, Row 1 does have a header.
I want/need to use a macro as I have merged cells and I have been told the only way I will get to sort my spreadsheet with merged cells is through a macro? ~ Please tell me if I have been wrongly informed.
When I searched the internet this was the result but I can't get it to work.
Code:
Sub SortDateTime()
On Error Resume Next
ActiveSheet.Unprotect
ActiveSheet.Range("A2:I998").Sort _
Key1:=Range("A2"), Order1:=xlAscending, _
Key2:=Range("B2"), Order2:=xlAscending, _
Header:=xlYes
ActiveSheet.Protect DrawingObjects:=True, _
Contents:=True, AllowFiltering:=True
End Sub
I do have other macros running and they are working perfectly.
Code:
Sub AutoFilterToDo()
On Error Resume Next
ActiveSheet.Unprotect
'check for filter, turn on if none exists
If Not ActiveSheet.AutoFilterMode Then
ActiveSheet.Range("A1:I1").AutoFilter
End If
'show tasks with no calculated hours
Range("A1:I1").AutoFilter Field:=7, Criteria1:=""
ActiveSheet.Protect DrawingObjects:=True, _
Contents:=True, AllowFiltering:=True
End Sub
Sub ClearFilter()
On Error Resume Next
ActiveSheet.Unprotect
'removes AutoFilter if one exists
ActiveSheet.AutoFilterMode = False
ActiveSheet.Protect DrawingObjects:=True, _
Contents:=True, AllowFiltering:=True
End Sub
Sub AutoFilterShowAll()
On Error Resume Next
ActiveSheet.Unprotect
'check for filter, turn on if none exists
If Not ActiveSheet.AutoFilterMode Then
ActiveSheet.Range("A1:I1").AutoFilter
End If
ActiveSheet.ShowAllData
ActiveSheet.Protect DrawingObjects:=True, _
Contents:=True, AllowFiltering:=True
End Sub
Are the above macros possibly interfering with the new sort macro that I am trying to add?
Like I said I am so new to macros the only thing that I change in a macro is the range to suit my needs. I did this with all the macros that you see.
The only one that is not doing anything is the Sort macro.
Can someone please help me with this, I realise that it is a big ask since I really don't know what I am doing with macros.
Any help/advice would be really appreciated.
Thanks in advance for reading this post and further Thanks if you are able to assist