Running a macro on an Excel spreadsheet, I get the Run-time error:
1004 Command could not be completed by using the range specified.
Selected Debug and the highlighted code is:
Selection.Subtotal GroupBy:=5, Function:=xlSum, TotalList:=Array(6, 7, 8, 9, _
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23), Replace:=True, _
PageBreaks:= False, SummaryBelowData:=True
Looking elsewhere and I find this generally means a sort was attempted while there was not a selected cell.
However, the line immediately prior to the highlighted code is:
SubRange.Select
And the two lines immediately following these two are essentially identical, just sorting a different section of the sheet:
SortRange.Select
Selection.Sort Key1:=Range("E4"), Order1:=xlAscending, Key2:=Range("A4") _
, Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1, MatchCase:= _
False, Orientation:=xlTopToBottom
Is the difference tied up in the SortRange.Select versus the SubRange.Select?
In testing I've found the error occurs when a certain column containing numeric values is imported as text versus being imported as General. The column data is numeric, but it has leading zeroes and are not to be mathematically manipulated and so, by good Excel practices, ought to be treated as text.
Any ideas what I ought to do to try and diagnose this?