ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   macro works at home but not at work (https://www.excelbanter.com/excel-programming/431757-macro-works-home-but-not-work.html)

markrennolds[_7_]

macro works at home but not at work
 

Hi All

I have a macro that works fine at home but on none of work pc's. I have
saved the document as an excel 97-2003 worksheet as that is what all
other users have done (and their macro's work fine). Most of the code
works apart from the sort section.

Any advice anyone? Here is the code, (its the xlSortOnValues that goes
wrong first, not sure if there will be other errors after that?)

Thanks
Mark


Code:
--------------------
'Sort
Sheets("Area Summary").Range("B7:M31").Select
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("Area Summary").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Area Summary").Sort.SortFields.Add Key:=Range( _
"M8:M31"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Area Summary").Sort.SortFields.Add Key:=Range( _
"E8:E31"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("Area Summary").Sort
.SetRange Range("B7:M31")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("B3").Select
End Sub
--------------------


--
markrennolds
------------------------------------------------------------------------
markrennolds's Profile: http://www.thecodecage.com/forumz/member.php?userid=543
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=120767


Don Guillett

macro works at home but not at work
 

Some "features" of 2007 such as this are not backward compatible. Develop in
your older version and simply save as a "microsoft excel file" which is
..xls. Should now run in all versions.

-
Don Guillett
Microsoft MVP Excel
SalesAid Software

"markrennolds" wrote in message
...

Hi All

I have a macro that works fine at home but on none of work pc's. I have
saved the document as an excel 97-2003 worksheet as that is what all
other users have done (and their macro's work fine). Most of the code
works apart from the sort section.

Any advice anyone? Here is the code, (its the xlSortOnValues that goes
wrong first, not sure if there will be other errors after that?)

Thanks
Mark


Code:
--------------------
'Sort
Sheets("Area Summary").Range("B7:M31").Select
Application.CutCopyMode = False
ActiveWorkbook.Worksheets("Area Summary").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Area Summary").Sort.SortFields.Add
Key:=Range( _
"M8:M31"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortNormal
ActiveWorkbook.Worksheets("Area Summary").Sort.SortFields.Add
Key:=Range( _
"E8:E31"), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:= _
xlSortTextAsNumbers
With ActiveWorkbook.Worksheets("Area Summary").Sort
.SetRange Range("B7:M31")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Range("B3").Select
End Sub
--------------------


--
markrennolds
------------------------------------------------------------------------
markrennolds's Profile:
http://www.thecodecage.com/forumz/member.php?userid=543
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=120767




All times are GMT +1. The time now is 01:20 AM.

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