Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Linking Groups of cells between workbooks | Excel Discussion (Misc queries) | |||
sort by groups in excel | Excel Discussion (Misc queries) | |||
Sort Groups of Cells | Excel Worksheet Functions | |||
How can I sort in groups of 3 rows? | Excel Worksheet Functions | |||
Linking Cells and applying a sort | Excel Worksheet Functions |