ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   sorting with macros (https://www.excelbanter.com/excel-discussion-misc-queries/10905-sorting-macros.html)

Sorting in macros

sorting with macros
 
I created a employee schedule and i dont want people adding rows and such to
i locked all cell except for the names of the employees which are list under
column A.
I set up a macros so that all the user has to do is add new employees at the
next availible row and delete any employees that have left. Then press a
macros button and the names list in column A sort in ABC order. The problem
is that when i set the macros it sorts correctly, and then i push the macros
button that i assigned it to and it does nothing. The strange thing is that
it works on other worksheet in the same workbook.
here is the code for the unworking macros.



Sub sortconc()
'
' sortconc Macro
' Macro recorded 1/31/2005 by palace
'

'
Range("A7:A80").Select
Selection.Sort Key1:=Range("A8"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A7").Select
End Sub


and here is the code that works for another sheet


Sub sortbox()
'
' sortbox Macro
' Macro recorded 5/5/2004 by Muvico Employee
'

'
Range("A7:A36").Select
Selection.Sort Key1:=Range("A7"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A7").Select
End Sub


any help would be great.

scott



Bob Phillips

Nothing obvious to me but I suggest you explicitly qualify the worksheet,
such as

Worksheets("Data Sheet").Range(A7:A80").Select

etc.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Sorting in macros" <Sorting in wrote in
message ...
I created a employee schedule and i dont want people adding rows and such

to
i locked all cell except for the names of the employees which are list

under
column A.
I set up a macros so that all the user has to do is add new employees at

the
next availible row and delete any employees that have left. Then press a
macros button and the names list in column A sort in ABC order. The

problem
is that when i set the macros it sorts correctly, and then i push the

macros
button that i assigned it to and it does nothing. The strange thing is

that
it works on other worksheet in the same workbook.
here is the code for the unworking macros.



Sub sortconc()
'
' sortconc Macro
' Macro recorded 1/31/2005 by palace
'

'
Range("A7:A80").Select
Selection.Sort Key1:=Range("A8"), Order1:=xlAscending,

Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A7").Select
End Sub


and here is the code that works for another sheet


Sub sortbox()
'
' sortbox Macro
' Macro recorded 5/5/2004 by Muvico Employee
'

'
Range("A7:A36").Select
Selection.Sort Key1:=Range("A7"), Order1:=xlAscending,

Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Range("A7").Select
End Sub


any help would be great.

scott






All times are GMT +1. The time now is 10:44 AM.

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