Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 1
Default Linking groups of cells in a row so they will sort together

Hello,

Never posted to the group before but have found lots of good advice.
I would like to find a way to link groups of cells in a row so they
will sort together when I sort in that row. My spreadsheet has 48
columns of data in each of the 15 rows. I would like to sort each row
by columns. In each row, the data in column 1 needs to stay next to
the data in column 2, column 3 needs to stay with column 4 and so on.
How do I write a macro that could sort by the value of the first
column in the pair in descending order and keep the value of the
second one in the pair in the column next to it. I have not written
macros before so I would appreciate as detailed advice as anyone is
willing to give.
Thanks,
Sam
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default Linking groups of cells in a row so they will sort together

Hi Sam,
If you just mean keeping all the data on the row together
sorting the rows by Column A then Column B

Sub Macro35()
Selection.Sort Key1:=Range("A2"), Order1:=xlAscending, _
Key2:=Range("B2"), Order2:=xlAscending, Header:=xlYes, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End Sub

hdr-A hdr-B hdr-C hdr-D
C 000 076 095
F 092 029 022
G 035 062 048
G 016 096 005
F 082 029 027
C 063 041 045

for a sorted version of

hdr-A hdr-B hdr-C hdr-D
C 000 076 095
C 063 041 045
F 082 029 027
F 092 029 022
G 016 096 005
G 035 062 048

The non programmed solution from which a macro was
recorded is:
1) Select all cells
2) Data, Sort,
Column A, Ascending
Column B, Ascending
my data has headers
---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Sam" wrote in message om...
Hello,

Never posted to the group before but have found lots of good advice.
I would like to find a way to link groups of cells in a row so they
will sort together when I sort in that row. My spreadsheet has 48
columns of data in each of the 15 rows. I would like to sort each row
by columns. In each row, the data in column 1 needs to stay next to
the data in column 2, column 3 needs to stay with column 4 and so on.
How do I write a macro that could sort by the value of the first
column in the pair in descending order and keep the value of the
second one in the pair in the column next to it. I have not written
macros before so I would appreciate as detailed advice as anyone is
willing to give.
Thanks,
Sam



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
Linking Groups of cells between workbooks vnacj-joe Excel Discussion (Misc queries) 4 June 14th 07 05:18 PM
sort by groups in excel staceyc Excel Discussion (Misc queries) 3 March 8th 06 10:07 PM
Sort Groups of Cells efenili Excel Worksheet Functions 3 March 2nd 06 07:25 PM
How can I sort in groups of 3 rows? Blue Excel Worksheet Functions 1 November 15th 05 10:11 PM
Linking Cells and applying a sort Destiny Excel Worksheet Functions 3 December 16th 04 09:13 PM


All times are GMT +1. The time now is 04:42 AM.

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"