Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 34
Default 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
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
pagebreaks after last department in a group, color header on first Janis Excel Programming 1 September 10th 06 04:57 AM
Taking age group Ie ages 20-29 and picking out net sales for group viabello Excel Worksheet Functions 1 April 25th 06 04:19 AM
I can't select/edit objects. It says [Group] on the header bar. Tomba Excel Discussion (Misc queries) 2 March 30th 06 12:09 PM
How do I group worksheets (Lotus 123 function is "Sheet>Group Shee jaking Excel Worksheet Functions 2 August 30th 05 02:09 PM
Sort by group DexterV New Users to Excel 4 July 8th 05 01:48 PM


All times are GMT +1. The time now is 07:25 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"