Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sort by Group Header or by Group SubHeader
Hello,
I'm perplexed on how to go about solving a Sorting problem in code. I have a group of rows with data listed across the columns ie. Row 3, Employee Name, [Name Input], Sales Yr, Jan, Feb, Mar, ...etc,Total. Row 4, Employee Number, [Number Input], Sales Yr, Jan, Feb, Mar, ...etc, Total. Row 5, Employee Status, [Status Input], Sales Yr, Jan, Feb, Mar, ...etc, Total. Row 6, Other Info, [Info Input], Sales Yr, Jan, Feb, Mar, ...etc, Total. This segment of data gets repeated down the sheet for each employee. Is there a way to sort by choosing the [Name Input] or by [Number Input] and keep each segment together? Thanks so much, Aria :) *** Sent via Developersdex http://www.developersdex.com *** |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sort by Group Header or by Group SubHeader
You can try something like this. This code swaps to ranges of cells.
Sub sortRange() myend = 100 For I = 0 To (myend - 1) For j = (I + 1) To myend Set FirstRange = _ Range("A1:P4").Offset(Rowoffset:=4 * I, columnoffset:=0) Set SecondRange = _ Range("A1:P4").Offset(Rowoffset:=4 * (j + 1), columnoffset:=0) FirstRange.Select FirstRange.Cut SecondRange.Select SecondRange.Insert (xlShiftDown) If (I + 1 < j) Then Set FirstRange = _ Range("A1:P4").Offset(Rowoffset:=4 * I, columnoffset:=0) Set SecondRange = _ Range("A1:P4").Offset(Rowoffset:=4 * (j - 1), columnoffset:=0) End If FirstRange.Select FirstRange.Cut SecondRange.Select SecondRange.Insert (xlShiftDown) Next j Next I End Sub "Aria" wrote: Hello, I'm perplexed on how to go about solving a Sorting problem in code. I have a group of rows with data listed across the columns ie. Row 3, Employee Name, [Name Input], Sales Yr, Jan, Feb, Mar, ...etc,Total. Row 4, Employee Number, [Number Input], Sales Yr, Jan, Feb, Mar, ...etc, Total. Row 5, Employee Status, [Status Input], Sales Yr, Jan, Feb, Mar, ...etc, Total. Row 6, Other Info, [Info Input], Sales Yr, Jan, Feb, Mar, ...etc, Total. This segment of data gets repeated down the sheet for each employee. Is there a way to sort by choosing the [Name Input] or by [Number Input] and keep each segment together? Thanks so much, Aria :) *** Sent via Developersdex http://www.developersdex.com *** |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sort by Group Header or by Group SubHeader
Hi Joel,
I've tried your suggestion and it kept on looping/running. It's my spreadsheet because I have about 17 rows (varies) of data per employee. So could you help me please, tweak your code so that it would recognize Employee Name title within Column A down to the next Employee Name title, and up 1 row as the entire segment to move/resort? The sort criteria is the Employee Name Input cell which is 1 column to the right of Employee Name title. Your help is greatly appreciated. Thanks, Aria :) *** Sent via Developersdex http://www.developersdex.com *** |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sort by Group Header or by Group SubHeader
"Aria" wrote: Hello, I'm perplexed on how to go about solving a Sorting problem in code. I have a group of rows with data listed across the columns ie. Row 3, Employee Name, [Name Input], Sales Yr, Jan, Feb, Mar, ...etc,Total. Row 4, Employee Number, [Number Input], Sales Yr, Jan, Feb, Mar, ...etc, Total. Row 5, Employee Status, [Status Input], Sales Yr, Jan, Feb, Mar, ...etc, Total. Row 6, Other Info, [Info Input], Sales Yr, Jan, Feb, Mar, ...etc, Total. This segment of data gets repeated down the sheet for each employee. Is there a way to sort by choosing the [Name Input] or by [Number Input] and keep each segment together? Thanks so much, Aria :) *** Sent via Developersdex http://www.developersdex.com *** |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Sort by Group Header or by Group SubHeader
Any help would be greatly appreciated.
Aria :) *** Sent via Developersdex http://www.developersdex.com *** |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
pagebreaks after last department in a group, color header on first | Excel Programming | |||
Taking age group Ie ages 20-29 and picking out net sales for group | Excel Worksheet Functions | |||
I can't select/edit objects. It says [Group] on the header bar. | Excel Discussion (Misc queries) | |||
How do I group worksheets (Lotus 123 function is "Sheet>Group Shee | Excel Worksheet Functions | |||
Sort by group | New Users to Excel |