Use macro to sort column

P

Paula

I have 3 columns of info-B,C,D.
I want to sort the numbers in D in ascending order, but I need the info in B
and C to stay with the number in D.
I do not want to do it through "sort" because 5 worksheets has 77 rows, and
the sorting is in sections in those 77 rows. If you can show me the macro for
the first section, Rows 6-18, I can figure out the rest. Please do not leave
anything out of the macro, like the beginning and the end words, because I
cannot write them, I can only edit the ranges.
Thank You!
Paula
 
L

Luke M

Macro to sorts B6:D18 by column D:

Sub SortByColumnD()
'Change first range as needed
'Do not change Key1
Range("B6:D18").Sort Key1:=Range("D1"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortTextAsNumbers
End Sub
 
P

Paula

It worked perfect-thanks!!

Luke M said:
Macro to sorts B6:D18 by column D:

Sub SortByColumnD()
'Change first range as needed
'Do not change Key1
Range("B6:D18").Sort Key1:=Range("D1"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortTextAsNumbers
End Sub
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*
 

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

Top