We have been provided an excel-vba file, which runs good on some machines, but on some machines following error is generated: run-time error 1004, application defined or user defined error, for following sequence:
sheetChoiceList.Sort.SortFields.Add key:=ThisWorkbook.Names("ChoiceList_AllChoices").RefersToRange.Columns(6), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
Sub:
Sub SortChoiceListForCurrentQuestionChoiceList()
' Sorts the Choice List based on the question type of the current question
' A formula in the sheet determines if the choice is applicable to the current question, returning a TRUE/FALSE
' A dyanamic named range uses the count of TRUE values to determine the number of rows extending down from row 2
' The sort is necessary to ensure that the TRUE values start on row 2
sheetChoiceList.Sort.SortFields.Clear
sheetChoiceList.Sort.SortFields.Add key:=ThisWorkbook.Names("ChoiceList_AllChoices").RefersToRange.Columns(6), _
SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal
With sheetChoiceList.Sort
.SetRange ThisWorkbook.Names("ChoiceList_AllChoices").RefersToRange
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub