Johnny Thunder
Well-known Member
- Joined
- Apr 9, 2010
- Messages
- 693
- Office Version
- 2016
- Platform
- MacOS
Hello All,
I am having the weirdest issue right now. I have a piece of code that was working great and now the code seems to be not working correctly or just not doing anything at all.
Here is the code
Not sure what happened to it but it was working fine before. Any ideas are helpful. This code is being triggered on Excel 2016 for Mac
This is the column of data that should be getting sorted but as you can see the data is unsorted.
Whenever I use this manually recorded script it runs just fine so what is the deal?
I am having the weirdest issue right now. I have a piece of code that was working great and now the code seems to be not working correctly or just not doing anything at all.
Here is the code
VBA Code:
Dailylog.Sort.SortFields.Clear
With Dailylog.Range("E4:X" & LastR1) 'Does the sorting on a specific range
.Sort Key1:=.Range("M3"), Order1:=xlAscending, Key2:=.Range("E3"), Order2:=xlAscending, Header:=xlYes
.EntireColumn.AutoFit
End With
Not sure what happened to it but it was working fine before. Any ideas are helpful. This code is being triggered on Excel 2016 for Mac
This is the column of data that should be getting sorted but as you can see the data is unsorted.
Daily Budget Log v2.6.xlsm | |||
---|---|---|---|
M | |||
3 | Date Received | ||
4 | 8/30/20 | ||
5 | 10/15/20 | ||
6 | 9/15/20 | ||
7 | |||
8 | |||
Daily Log |
Whenever I use this manually recorded script it runs just fine so what is the deal?
VBA Code:
Sub Macro2()
ActiveSheet.Range("E3:X8").Select
ActiveWorkbook.Worksheets("Daily Log").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Daily Log").Sort.SortFields.Add2 Key:=Range( _
"M4:M8"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Daily Log").Sort.SortFields.Add2 Key:=Range( _
"E4:E8"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Daily Log").Sort
.SetRange Range("E3:X8")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub
Last edited: