fishysheep
Programmer
Hi
vb prog with excel reference to 2 workbooks each with multiple sheets. Have selected x amount of rows (and I can see that this is correct because they are highlighted in front of me).
If I sort the same rows in excel then all is fine, but I can't seem to sort them via vb. I think the problem is that key1 isn't referring to the correct worksheet/workbook. I've tried activating the sheet first (didn't work), and also the following:
Selection.Sort Key1:=Range("T1400"), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortTextAsNumbers
*also*
Selection.Sort Key1:=xlsummary.Range("T1400"), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortTextAsNumbers
*also* (and this returns error)
Selection.Sort Key1:=xlwb.Worksheets("Summary").Range("T1400"), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortTextAsNumbers
Just to recap, the selection and the cell address of key1 in the sort statement are fine, and yes the key1 cell ref is part of the selection - checked and rechecked... but it still doesn't sort!
thank you!
vb prog with excel reference to 2 workbooks each with multiple sheets. Have selected x amount of rows (and I can see that this is correct because they are highlighted in front of me).
If I sort the same rows in excel then all is fine, but I can't seem to sort them via vb. I think the problem is that key1 isn't referring to the correct worksheet/workbook. I've tried activating the sheet first (didn't work), and also the following:
Selection.Sort Key1:=Range("T1400"), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortTextAsNumbers
*also*
Selection.Sort Key1:=xlsummary.Range("T1400"), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortTextAsNumbers
*also* (and this returns error)
Selection.Sort Key1:=xlwb.Worksheets("Summary").Range("T1400"), _
Order1:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortTextAsNumbers
Just to recap, the selection and the cell address of key1 in the sort statement are fine, and yes the key1 cell ref is part of the selection - checked and rechecked... but it still doesn't sort!
thank you!