excelbytes
Active Member
- Joined
- Dec 11, 2014
- Messages
- 298
- Office Version
- 365
- Platform
- Windows
I wrote VBA code for sorts a list of names in a table. It runs fine on my computer using Microsoft 365, but won't run on a computer using Excel 2010. There are other macros that run fine, just this one is an issue. Is there a property of method that I'm using in the code that wasn't available in Excel 2010? I highlighted the line of code that causes the error.
VBA Code:
Sub SortMembers()
'
' SortMembers Macro
ActiveSheet.Unprotect Password:="JesusLovesMe"
Range("A3").Select
Range(Selection, Selection.End(xlDown)).Select
ActiveWorkbook.Worksheets("Individual Contributions").ListObjects("Table1"). _
Sort.SortFields.Clear
[B][COLOR=rgb(184, 49, 47)] ActiveWorkbook.Worksheets("Individual Contributions").ListObjects("Table1"). _[/COLOR][/B]
[COLOR=rgb(184, 49, 47)][B] Sort.SortFields.Add2 Key:=Range("Table1[Members]"), SortOn:=xlSortOnValues _[/B][/COLOR]
[B][COLOR=rgb(184, 49, 47)] , Order:=xlAscending, DataOption:=xlSortNormal[/COLOR][/B]
With ActiveWorkbook.Worksheets("Individual Contributions").ListObjects("Table1" _
).Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True, Password:="JesusLovesMe"
End Sub