I've done this in Excel macros but can't seem to get it to work in VB.net.
I get the following error: system.Runtime.InteropService.COMException: 'This can't be done on multiple range selection. Select a single range and try again.'
I tried a single range with the same results. Here is the code:
Code:myRangeMakeup = "D" & StartScoreRow & ",F" & LastScoreRow mySortKey = "D" & StartScoreRow Debug.Print(myRangeMakeup) ' Prints D1065,F1123 Debug.Print(mySortKey) 'Prints D1065 myRange = xlWs.Range(myRangeMakeup) ' IS: D1065,F1123 and valid myRange.Select() myRange.Sort(Key1:=myRange.Range(mySortKey), Header:=XlYesNoGuess.xlNo, Order1:=XlSortOrder.xlAscending, MatchCase:=False, Orientation:=XlSortOrientation.xlSortColumns)
Debug prints the appropriate ranges.
Had one comment about a , instead of a : between the ranges but tried both with same results.
Also, the continuation underscore keeps disappearing when I put it in.




Reply With Quote
