Sorting based on a cell

  • Thread starter Thread starter scottwilsonx
  • Start date Start date
S

scottwilsonx

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
 
Try changing line:
Range("B2").Value = SortMonth

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top