Run time error '438' after recording macros in 07 excel and attempting to run in 03

pacer31

New Member
Joined
May 2, 2010
Messages
7
cross listed here: http://www.excelforum.com/excel-wor...n-07-excel-and-attempting-to-run-in-03-a.html

Hi there,

I recorded a handful of simple sorting macros in Excel 07 but when I try to run them in 03 they return "Run time error '438': object doesn't support this property or method". When I hit debug the bolded line is highlighted:

Sub CCMMfinal()
'
' CCMMfinal Macro
'

'
Range("A2:H1701").Select
ActiveWorkbook.Worksheets("Credit Card").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Credit Card").Sort.SortFields.Add Key:=Range( _
"A3:A626"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Credit Card").Sort.SortFields.Add Key:=Range( _
"B3:B626"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortNormal
With ActiveWorkbook.Worksheets("Credit Card").Sort
.SetRange Range("A2:H626")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub

What am I to do? Thanks!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Hi pacer31

The SortFields property was only added in Excel 2007. Use the sort method directly using Key1 and Key2.
 
Upvote 0
Thanks for the response!
Sorry I have little experience in writing vba code and a simple find and replace didn't work. Is there a tool that rewrites it compatible with 2003? Or could you help me make the changes?
 
Upvote 0
Hi

Try:

Code:
Range("A2:H1701").Sort _
    key1:=Range("A3"), Order1:=xlAscending, _
    Key2:=Range("B3"), Order2:=xlAscending, _
    Header:=xlYes, _
    OrderCustom:=1, _
    MatchCase:=False, _
    Orientation:=xlTopToBottom
 
Upvote 0
thank you thank you!
it worked perfect, and was able to make the rest of my macro buttons from your example

edit: Mods, the edit option is gone from the original post but this is solved! thanks
 
Upvote 0
pgc (or anyone), I'm getting an error due to a similar situation, and am not familiar enough with vba coding to restucture it to meet my needs. The code below was created in excel 2007 and is not compatibile with excel 2003:

Sub LastName()
'
' LastName Macro
'
'
Range("A1").Select
ActiveWorkbook.Worksheets("Phone List").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Phone List").Sort.SortFields.Add Key:=Range("A1") _
, SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("Phone List").Sort
.SetRange Range("A2:J500")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End Sub


Help please???
 
Upvote 0
Hi
Welcome to the board

This should be close to what you need.

I'm just leaving but I'll check this thread later.

Code:
Sub LastName()
 
ActiveWorkbook.Worksheets("Phone List").Range("A2:J500").Sort _
    key1:=Range("A1"), order1:=xlAscending, DataOption1:=xlSortTextAsNumbers, _
    Header:=xlNo, _
    MatchCase:=False, _
    Orientation:=xlTopToBottom, _
    SortMethod:=xlPinYin
 
End Sub

Remark: I noticed in your code that the data is in the worksheet "Phone List", but your key to sorting (Range("A1")) is in the activesheet?
 
Last edited:
Upvote 0
Thanks-I took your suggestion below:
Sub LastName()

ActiveWorkbook.Worksheets("Phone List").Range("A2:J500").Sort _
key1:=Range("A1"), order1:=xlAscending, DataOption1:=xlSortTextAsNumbers, _
Header:=xlNo, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
SortMethod:=xlPinYin

End Sub


and was coming up with a 1004 range error, so I played with the sort method coding (SortMethod:=xl) and it seems to be working for excel 2003. Thanks for the assistance
 
Upvote 0

Forum statistics

Threads
1,215,692
Messages
6,126,227
Members
449,303
Latest member
grantrob

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top