Sort macro by same columns

  • Thread starter Thread starter Kevin Sprinkel
  • Start date Start date
K

Kevin Sprinkel

I'd like a general sort macro that will sort the selected
rows in our Schedule spreadsheet, always by the same two
columns, with no header rows.

After creating a recorded one, the code specifies the top
cell in each column in the Key# criteria. This will in
general, be different each time.

TIA
Kevin Sprinkel
 
Just use the top cell of the column as the Key1 and Key2 criteria:

Key1:= Range("A1"), Key2:= Range("B1")

Or am I misunderstanding you?
 
This would sort all rows; I want only to sort the selected
range. So what would be useful is a function that
returned the top row of the selected range, so that I
could build the Key1, Key2 criteria:

Dim strK1 as String
strK1 = "A" & strval(<RowReturnedfromFunction>)
Key1:=Range(strK1)

Can you point me in the right direction?

Thank you.
Kevin Sprinkel
 
Did you try it?

--

Vasant

Kevin Sprinkel said:
This would sort all rows; I want only to sort the selected
range. So what would be useful is a function that
returned the top row of the selected range, so that I
could build the Key1, Key2 criteria:

Dim strK1 as String
strK1 = "A" & strval(<RowReturnedfromFunction>)
Key1:=Range(strK1)

Can you point me in the right direction?

Thank you.
Kevin Sprinkel
 

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