Macro Help, Please!

M

mrajoo

Hi Everyone,

My Excel 2007 macro is not working in Excel 2003 as i'm getting a run-time
error '438' Object doesn't support this property or method as below. Any
help will be highly appreciated.

Sub SortByExport()
'
' SortByExport Macro
' Sort by Export column (prior to copying to Notepad).
'
' Keyboard Shortcut: Ctrl+Shift+S
' Recorded in Office 2007, then edited

Range("A1:H257").Select

'In Office 2003, the macro stops on the following line with the error
'message, "Object doesn't support this property or method":
ActiveWorkbook.Worksheets("Export").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Export").Sort.SortFields.Add
Key:=Range("H2:H257") _
, SortOn:=xlSortOnValues, Order:=xlDescending,
DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Export").Sort
.SetRange Range("A1:H257")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Range("A1").Select

End Sub
 
J

Jim Thomlinson

Sorting is quite a bit differnet in 2007. Try this in 2003

Sub SortByExport()
'
' SortByExport Macro
' Sort by Export column (prior to copying to Notepad).
'
' Keyboard Shortcut: Ctrl+Shift+S
' Recorded in Office 2007, then edited

Range("A1:H257").Sort Key1:=Range("H2"), Order1:=xlDescending, _
Header:=xlYes

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Modify Sort Routine to inlcude All Data 2
Undo Macro Action 3
Sorting Question 5
Sort Macro Compatibility 3
run multiple macros from drop down list 12
VBA 2 Codes 2
Clear Check Box 2
Pictures not being sorted in VBA 2

Top