Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Sorting based on a cell


Thanks to Tom who replied to my earlier email.
I have made some alterations, which are detailed below:

Data range from B5 to Z37 where row 5 is the header showing Apr-03 t
Mar-05 in C5 to Z5. and where column B contains the row headers.

My sort macro looks like this:

Sub SORT()
Dim SortMonth As Integer
Range("B2").Value = SortMonth
Range("B5:Z37").Select
Selection.SORT Key1:=Range(SortMonth), Order1:=xlAscending
End Sub

It isn't working properly. I have created a SortMonth dimension whic
is based on the value in cell B2. What I would like to do is where th
Selection.Sort looks for a range, I want it to look in B2 and take tha
value, which is equivalent to the months in C5 to Z5.

Thanks for your help.

Regards

Scott

--
scottwilson
-----------------------------------------------------------------------
scottwilsonx's Profile: http://www.excelforum.com/member.php...fo&userid=1112
View this thread: http://www.excelforum.com/showthread.php?threadid=26638

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 430
Default Sorting based on a cell

Try changing line:
Range("B2").Value = SortMonth

to:
SortMonth = Range("B2").Value


"scottwilsonx" wrote in message
...

Thanks to Tom who replied to my earlier email.
I have made some alterations, which are detailed below:

Data range from B5 to Z37 where row 5 is the header showing Apr-03 to
Mar-05 in C5 to Z5. and where column B contains the row headers.

My sort macro looks like this:

Sub SORT()
Dim SortMonth As Integer
Range("B2").Value = SortMonth
Range("B5:Z37").Select
Selection.SORT Key1:=Range(SortMonth), Order1:=xlAscending
End Sub

It isn't working properly. I have created a SortMonth dimension which
is based on the value in cell B2. What I would like to do is where the
Selection.Sort looks for a range, I want it to look in B2 and take that
value, which is equivalent to the months in C5 to Z5.

Thanks for your help.

Regards

Scott.


--
scottwilsonx
------------------------------------------------------------------------
scottwilsonx's Profile:

http://www.excelforum.com/member.php...o&userid=11128
View this thread: http://www.excelforum.com/showthread...hreadid=266388



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
sorting columns when cell results based on other cells Dawn Excel Worksheet Functions 1 May 20th 08 05:52 AM
sorting worksheets based on a cell value Patrick Excel Worksheet Functions 3 May 2nd 06 06:49 PM
Sorting cell data based on values veronica Excel Discussion (Misc queries) 1 January 25th 06 08:25 PM
Excel should allow sorting and filtering based on cell color. Linda Excel Worksheet Functions 3 June 20th 05 05:18 PM
Sorting data based on validation cell JanetP[_2_] Excel Programming 1 January 7th 04 05:39 PM


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

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

About Us

"It's about Microsoft Excel"