#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 164
Default Macro Help

I have a macro which sorts a shopping list in the order of the stores that I
do my grocery shopping, that I created using the create a macro option in I
believe 2003, now using 2007, code below. Unfortunately if I add more items
to the list and forget to change the macro end range things don't get sorted
in the proper order. Is there any way that I can change the range so that
regardless of the number of items in the list the macro will work properly?

Sub SortShoppingList()
'
' SortShoppingList Macro
' Macro recorded 15/12/2006 by Michael Koerner
'

'
Range("A1").Select
Selection.AutoFilter Field:=4, Criteria1:="<"
Range("A1:G1741").Sort Key1:=Range("E2"), Order1:=xlDescending, Key2:= _
Range("B2"), Order2:=xlAscending, Key3:=Range("C2"),
Order3:=xlAscending _
, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal,
_
DataOption3:=xlSortNormal
End Sub


--

Regards
Michael Koerner



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,069
Default Macro Help

You had some resonses to this question in your first post.
--
jb


"Michael Koerner" wrote:

I have a macro which sorts a shopping list in the order of the stores that I
do my grocery shopping, that I created using the create a macro option in I
believe 2003, now using 2007, code below. Unfortunately if I add more items
to the list and forget to change the macro end range things don't get sorted
in the proper order. Is there any way that I can change the range so that
regardless of the number of items in the list the macro will work properly?

Sub SortShoppingList()
'
' SortShoppingList Macro
' Macro recorded 15/12/2006 by Michael Koerner
'

'
Range("A1").Select
Selection.AutoFilter Field:=4, Criteria1:="<"
Range("A1:G1741").Sort Key1:=Range("E2"), Order1:=xlDescending, Key2:= _
Range("B2"), Order2:=xlAscending, Key3:=Range("C2"),
Order3:=xlAscending _
, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal,
_
DataOption3:=xlSortNormal
End Sub


--

Regards
Michael Koerner




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 164
Default Macro Help

Sorry about that. It did not show up when I first checked for it

--

Regards
Michael Koerner


"john" wrote in message
...
You had some resonses to this question in your first post.
--
jb


"Michael Koerner" wrote:

I have a macro which sorts a shopping list in the order of the stores that
I
do my grocery shopping, that I created using the create a macro option in
I
believe 2003, now using 2007, code below. Unfortunately if I add more
items
to the list and forget to change the macro end range things don't get
sorted
in the proper order. Is there any way that I can change the range so that
regardless of the number of items in the list the macro will work
properly?

Sub SortShoppingList()
'
' SortShoppingList Macro
' Macro recorded 15/12/2006 by Michael Koerner
'

'
Range("A1").Select
Selection.AutoFilter Field:=4, Criteria1:="<"
Range("A1:G1741").Sort Key1:=Range("E2"), Order1:=xlDescending, Key2:=
_
Range("B2"), Order2:=xlAscending, Key3:=Range("C2"),
Order3:=xlAscending _
, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:=
_
xlTopToBottom, DataOption1:=xlSortNormal,
DataOption2:=xlSortNormal,
_
DataOption3:=xlSortNormal
End Sub


--

Regards
Michael Koerner






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,298
Default Macro Help

and another ....

Range(Range("A1"), Range("G1").End(xlDown) ).Sort Key1:=Range("E2"),
Order1:=xlDescending, Key2:= Range("B2"), Order2:=xlAscending,
Key3:=Range("C2"), Order3:=xlAscending



"Michael Koerner" wrote:

I have a macro which sorts a shopping list in the order of the stores that I
do my grocery shopping, that I created using the create a macro option in I
believe 2003, now using 2007, code below. Unfortunately if I add more items
to the list and forget to change the macro end range things don't get sorted
in the proper order. Is there any way that I can change the range so that
regardless of the number of items in the list the macro will work properly?

Sub SortShoppingList()
'
' SortShoppingList Macro
' Macro recorded 15/12/2006 by Michael Koerner
'

'
Range("A1").Select
Selection.AutoFilter Field:=4, Criteria1:="<"
Range("A1:G1741").Sort Key1:=Range("E2"), Order1:=xlDescending, Key2:= _
Range("B2"), Order2:=xlAscending, Key3:=Range("C2"),
Order3:=xlAscending _
, Header:=xlGuess, OrderCustom:=1, MatchCase:=False, Orientation:= _
xlTopToBottom, DataOption1:=xlSortNormal, DataOption2:=xlSortNormal,
_
DataOption3:=xlSortNormal
End Sub


--

Regards
Michael Koerner




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
AutoRun Macro with a delay to give user the choice to cancel the macro wanderlust Excel Programming 2 September 28th 07 04:09 PM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
how to count/sum by function/macro to get the number of record to do copy/paste in macro tango Excel Programming 1 October 15th 04 01:16 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


All times are GMT +1. The time now is 10:58 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"