ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Any way to save VBA code so it works with older Excel revisions? (https://www.excelbanter.com/excel-programming/361587-any-way-save-vba-code-so-works-older-excel-revisions.html)

fugazi48

Any way to save VBA code so it works with older Excel revisions?
 
The programming below was recorded and modified in Excel 2003, it fails on
Excel 2000. Is there a way to save the file or convert it to make it work in
Excel 2000 without having to sit down and debug all of what is
non-compatible? I doubt there is, but thought I would see if there was a
quick and easy way. Thanks.

Range("A16:P500").Select
Selection.Copy

Range("S16").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False

Application.CutCopyMode = False
Selection.Sort Key1:=Range("AG17"), Order1:=xlAscending, Key2:=Range( _
"af17"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal

Bob Phillips[_14_]

Any way to save VBA code so it works with older Excel revisions?
 
The trick is to develop the code in the earliest version it will be used in.
If you can't do that, you need to identify any changes in later versions
and avoid that code. If you can't do that, then you are left with fixing it
when it happens.

In this case, Excel 200 doesn't use DataOption1/2 arguments, so just remove
them

--
HTH

Bob Phillips

(remove xxx from email address if mailing direct)

"fugazi48" wrote in message
...
The programming below was recorded and modified in Excel 2003, it fails on
Excel 2000. Is there a way to save the file or convert it to make it work

in
Excel 2000 without having to sit down and debug all of what is
non-compatible? I doubt there is, but thought I would see if there was a
quick and easy way. Thanks.

Range("A16:P500").Select
Selection.Copy

Range("S16").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False

Application.CutCopyMode = False
Selection.Sort Key1:=Range("AG17"), Order1:=xlAscending,

Key2:=Range( _
"af17"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal




Tom Ogilvy

Any way to save VBA code so it works with older Excel revisions?
 
the easiest way is to do your recording in the lowest version that will use
the code.

There is no option to save it to be compatible with an older version.

--
regards,
Tom Ogilvy



"fugazi48" wrote:

The programming below was recorded and modified in Excel 2003, it fails on
Excel 2000. Is there a way to save the file or convert it to make it work in
Excel 2000 without having to sit down and debug all of what is
non-compatible? I doubt there is, but thought I would see if there was a
quick and easy way. Thanks.

Range("A16:P500").Select
Selection.Copy

Range("S16").Select
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats,
Operation:= _
xlNone, SkipBlanks:=False, Transpose:=False

Application.CutCopyMode = False
Selection.Sort Key1:=Range("AG17"), Order1:=xlAscending, Key2:=Range( _
"af17"), Order2:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase _
:=False, Orientation:=xlTopToBottom, DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal



All times are GMT +1. The time now is 12:18 PM.

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