Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
I am trying to sort a few columns. This is the code I have. It does not work
it tells me that the sort reference is not valid Sub Macro2() Dim AKO As Range Dim BKO as Range Set AKO = Range(Sheet3.Cells(2, 13), Sheet3.Cells(362, 66)) 'Range("M2:M362") Set BKO = Range(Sheet3.Cells(2, 13), Sheet3.Cells(362, 13)) 'Range("M2:M362") ActiveWorkbook.Worksheets("RESULTS").Sort.SortFiel ds.Clear ActiveWorkbook.Worksheets("RESULTS").Sort.SortFiel ds.Add Key:=AKO, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("RESULTS").Sort .SetRange BKO .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With End Sub |
#2
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Hi,
Am Fri, 19 Oct 2012 13:35:45 -0700 (PDT) schrieb tuli: Dim AKO As Range Dim BKO as Range Set AKO = Range(Sheet3.Cells(2, 13), Sheet3.Cells(362, 66)) 'Range("M2:M362") Set BKO = Range(Sheet3.Cells(2, 13), Sheet3.Cells(362, 13)) 'Range("M2:M362") try: Set AKO = Sheets("Sheet3").Range(Cells(2, 13), Cells(362, 13)) or: Set AKO = Sheets("Sheet3").Range("M2:M362") change your code: Dim AKO As Range Dim BKO As Range With Worksheets("RESULTS") Set AKO = .Range(Cells(2, 13), Cells(362, 13)) Set BKO = Range(Cells(1, 1), Cells(362, 13)) .Sort.SortFields.Clear .Sort.SortFields.Add Key:=AKO _ , SortOn:=xlSortOnValues, Order:=xlAscending, _ DataOption:=xlSortNormal With .Sort .SetRange BKO .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With End With Regards Claus Busch -- Win XP PRof SP2 / Vista Ultimate SP2 Office 2003 SP2 /2007 Ultimate SP2 |
#3
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
Hi,
Am Fri, 19 Oct 2012 23:05:31 +0200 schrieb Claus Busch: Set AKO = .Range(Cells(2, 13), Cells(362, 13)) Set BKO = Range(Cells(1, 1), Cells(362, 13)) look for the 2 rows above and change them to: Set AKO = .Range(.Cells(2, 13), .Cells(362, 13)) Set BKO = .Range(.Cells(1, 1), .Cells(362, 13)) Regards Claus Busch -- Win XP PRof SP2 / Vista Ultimate SP2 Office 2003 SP2 /2007 Ultimate SP2 |
#4
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
On Friday, October 19, 2012 4:35:46 PM UTC-4, tuli wrote:
I am trying to sort a few columns. This is the code I have. It does not work it tells me that the sort reference is not valid Sub Macro2() Dim AKO As Range Dim BKO as Range Set AKO = Range(Sheet3.Cells(2, 13), Sheet3.Cells(362, 66)) 'Range("M2:M362") Set BKO = Range(Sheet3.Cells(2, 13), Sheet3..Cells(362, 13)) 'Range("M2:M362") ActiveWorkbook.Worksheets("RESULTS").Sort.SortFiel ds.Clear ActiveWorkbook.Worksheets("RESULTS").Sort.SortFiel ds.Add Key:=AKO, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("RESULTS").Sort .SetRange BKO .Header = xlYes .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With End Sub Thanks this worked |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Range definition | Excel Programming | |||
Range Definition | Excel Programming | |||
Using Address in Range Definition?? | Excel Programming | |||
How come this range definition is invalid? | Excel Programming | |||
Using Cells( ) for Range definition | Excel Programming |