ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro Help, Please! (https://www.excelbanter.com/excel-programming/424566-macro-help-please.html)

mrajoo

Macro Help, Please!
 
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.SortField s.Clear
ActiveWorkbook.Worksheets("Export").Sort.SortField s.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

Jim Thomlinson

Macro Help, Please!
 
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
--
HTH...

Jim Thomlinson


"mrajoo" wrote:

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.SortField s.Clear
ActiveWorkbook.Worksheets("Export").Sort.SortField s.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



All times are GMT +1. The time now is 11:49 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com