Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22
Default Moving "sort by column"

I am trying to write a macro to automatically sort a small section of a
database of stock prices (see below) by referencing the column where the
current date is located, currently at "AW5".

Code 17/07/06 18/07/06 19/07/06
AAC 1.80 1.85 1.86
AAE 0.64 0.63 0.63
AAI 42.75 42.75 42.75
AAM 0.24 0.22 0.21
AAO 0.14 0.15 0.15

At this point, Excel generated the following codes for me:

Selection.Sort Key1:=Range("AW5"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

However, after adding a new set of column data the next day, the date
location changes to "AX5", and the "sort by column" is now one column to the
right. How can I modify the macro to automatically sort by the new "date
column" ? Any help would be much appreciated.

TIA
Brian


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,942
Default Moving "sort by column"

hi,
i assume that since you add a column each day that all the columns to the
right are blank. if so then this may do what you want.

sub sortmovecol()
Range("IV5").End(xlToLeft).Select
ActiveSheet.UsedRange.Sort Key1:=Selection, Order1:=xlAscending,
Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
end sub

regards
FSt1

"brian" wrote:

I am trying to write a macro to automatically sort a small section of a
database of stock prices (see below) by referencing the column where the
current date is located, currently at "AW5".

Code 17/07/06 18/07/06 19/07/06
AAC 1.80 1.85 1.86
AAE 0.64 0.63 0.63
AAI 42.75 42.75 42.75
AAM 0.24 0.22 0.21
AAO 0.14 0.15 0.15

At this point, Excel generated the following codes for me:

Selection.Sort Key1:=Range("AW5"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

However, after adding a new set of column data the next day, the date
location changes to "AX5", and the "sort by column" is now one column to the
right. How can I modify the macro to automatically sort by the new "date
column" ? Any help would be much appreciated.

TIA
Brian



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
Moving between cells Bails Excel Discussion (Misc queries) 5 July 7th 06 06:00 PM
Weighted moving average Boom1 Excel Worksheet Functions 0 June 1st 06 08:47 PM
Moving Average projection? Wild Nerd Excel Worksheet Functions 6 March 21st 06 01:55 PM
How to pick one or more items out of a list, moving to new list, moving up or down. (form) Subteam Excel Discussion (Misc queries) 3 February 17th 06 04:13 AM
Plotting moving average line on a chart Herbert Chan Charts and Charting in Excel 1 February 26th 05 08:31 PM


All times are GMT +1. The time now is 05:48 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"