Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim LastRow99 As Long
LastRow99 = .Cells(.Rows.Count, "A").End(xlUp).Row ActiveWorkbook.Worksheets("Working Sheet").Sort.SortFields.Clear ActiveWorkbook.Worksheets("Working Sheet").Sort.SortFields.Add Key:=Range( _ LastRow99), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _ xlSortNormal I get Run-time error '1004': Method 'Range' of object '_Global' failed |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You pass Long as argument to Range.
May be, you should redefine LastRow99, and use End(xlUp).EntireRow range |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I get a data type mismatch error now
On Sep 12, 4:30*pm, NOPIK wrote: You pass Long as argument to Range. May be, you should redefine LastRow99, and use End(xlUp).EntireRow range |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You have to specify the range that you want sorted. I used A1 through X(lastrow
in column A). You'll want to change that to use the column you need. Dim LastRow99 As Long with activeworkbook.worksheets("working sheet") lastRow99 = .Cells(.Rows.Count, "A").End(xlUp).Row .Sort.SortFields.Clear .Sort.SortFields.Add Key:=.Range("A1:X" & LastRow99), _ SortOn:=xlSortOnValues, Order:=xlAscending, _ DataOption:=xlSortNormal S Himmelrich wrote: Dim LastRow99 As Long LastRow99 = .Cells(.Rows.Count, "A").End(xlUp).Row ActiveWorkbook.Worksheets("Working Sheet").Sort.SortFields.Clear ActiveWorkbook.Worksheets("Working Sheet").Sort.SortFields.Add Key:=Range( _ LastRow99), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _ xlSortNormal I get Run-time error '1004': Method 'Range' of object '_Global' failed -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
needing to sort on column A, C, F & G
On Sep 12, 5:40*pm, Dave Peterson wrote: You have to specify the range that you want sorted. *I used A1 through X(lastrow in column A). *You'll want to change that to use the column you need. Dim LastRow99 As Long with activeworkbook.worksheets("working sheet") * * lastRow99 = .Cells(.Rows.Count, "A").End(xlUp).Row * * .Sort.SortFields.Clear * * .Sort.SortFields.Add Key:=.Range("A1:X" & LastRow99), _ * * * * *SortOn:=xlSortOnValues, Order:=xlAscending, _ * * * * *DataOption:=xlSortNormal S Himmelrich wrote: Dim LastRow99 As Long LastRow99 = .Cells(.Rows.Count, "A").End(xlUp).Row * * ActiveWorkbook.Worksheets("Working Sheet").Sort.SortFields.Clear * * ActiveWorkbook.Worksheets("Working Sheet").Sort.SortFields.Add Key:=Range( _ * * * * LastRow99), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _ * * * * xlSortNormal *I get Run-time error '1004': * Method 'Range' of object '_Global' failed -- Dave Peterson |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Record a macro when you do it manually. Remember, since you're sorting on 4
fields, you'll have to do the sort twice. S Himmelrich wrote: needing to sort on column A, C, F & G On Sep 12, 5:40 pm, Dave Peterson wrote: You have to specify the range that you want sorted. I used A1 through X(lastrow in column A). You'll want to change that to use the column you need. Dim LastRow99 As Long with activeworkbook.worksheets("working sheet") lastRow99 = .Cells(.Rows.Count, "A").End(xlUp).Row .Sort.SortFields.Clear .Sort.SortFields.Add Key:=.Range("A1:X" & LastRow99), _ SortOn:=xlSortOnValues, Order:=xlAscending, _ DataOption:=xlSortNormal S Himmelrich wrote: Dim LastRow99 As Long LastRow99 = .Cells(.Rows.Count, "A").End(xlUp).Row ActiveWorkbook.Worksheets("Working Sheet").Sort.SortFields.Clear ActiveWorkbook.Worksheets("Working Sheet").Sort.SortFields.Add Key:=Range( _ LastRow99), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _ xlSortNormal I get Run-time error '1004': Method 'Range' of object '_Global' failed -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Defining cells that macro will change | Excel Worksheet Functions | |||
defining names in a macro | Excel Discussion (Misc queries) | |||
Macro or VBA process varible row data | Excel Programming | |||
Macro that sums cells in rows of varible number and.... | Excel Programming | |||
How to approach defining where macro looks? | Excel Programming |