Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default How to group

Hi,
I have a spreadsheet with the following columns:

Item # 1 to 1000
Account Number alphanumeric 20 characters long
Amount 1
Amount 2
Period 1
Period 2

Data is currently sorted by Amount 2 ( largest to smallest).

There are multiple entries for the same account.

What I want to do is now group the data so that All the same account
numbers are grouped together along with all other fields but in this
grouping I want the amounts to keep the current sort largest to
smallest ( largest to smallest).If an account as three numbers I want
them on the sheet in consecutive lines

Thanks for all your help,
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 99
Default How to group

Hi Dave,

In Exel 2007 I recorded this macro for you:

Sub Dave()
'
' Dave Macro
'

' Select area with data
Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select

' Sort Acsending on account nd descending on Amount 2
ActiveWorkbook.Worksheets("Blad1").Sort.SortFields .Clear
ActiveWorkbook.Worksheets("Blad1").Sort.SortFields .Add _
Key:=Range("B2:B81"), SortOn:=xlSortOnValues, _
Order:=xlAscending, DataOption:=xlSortNormal
ActiveWorkbook.Worksheets("Blad1").Sort.SortFields .Add _
Key:=Range("D2:D81"), SortOn:=xlSortOnValues, _
Order:=xlDescending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Blad1").Sort
.SetRange Range("A1:F81")
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
' Group on Account with as bonus totals
Selection.Subtotal GroupBy:=2, Function:=xlSum, _
TotalList:=Array(3, 4), Replace:=True, _
PageBreaks:=False, SummaryBelowData:=True
End Sub


HTH,

Wouter
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
Range.Group Method - group rows, not columns serhio[_2_] Excel Programming 1 May 7th 08 01:26 PM
Group a range - closing the group does not hide the controls.... [email protected] Excel Programming 0 April 21st 07 04:53 AM
Sort by Group Header or by Group SubHeader Aria[_2_] Excel Programming 4 February 28th 07 01:07 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
How do I group worksheets (Lotus 123 function is "Sheet>Group Shee jaking Excel Worksheet Functions 2 August 30th 05 02:09 PM


All times are GMT +1. The time now is 06:08 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"