ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   subtotals and sorts (https://www.excelbanter.com/excel-discussion-misc-queries/131790-subtotals-sorts.html)

SheriTingle

subtotals and sorts
 
Hi and thanks for the help. I am using Excel 2003. I have a spreadsheet with
about 200 rows and 5 columns of data. There are numerous rows that hold
subtotals.

I need to sort based on the subtotals--BUT keep all the rows together that
belong with that subtotal. Is that possible??



joel

subtotals and sorts
 
I can be done with a custom macro. The macro would need find the continuous
rows associated with each subtotal. The swap the two groups. It would be a
bubble sort routine which swaps multiple rows of data. the general form of a
buble sort is

for i = 1 to (lastrow - 1)
For j = (i + 1) to lastrow

if (subtotal_blocki subtotal_blockj) then

temp_block = blocki
blocki = blockj
blockj =temp_block

end if
next j
next i

the block sizes may not be the same number of rows, do instead of swapping
some combination of .copy, .insert.entirerow, and .delete.entirerow would be
used.
"SheriTingle" wrote:

Hi and thanks for the help. I am using Excel 2003. I have a spreadsheet with
about 200 rows and 5 columns of data. There are numerous rows that hold
subtotals.

I need to sort based on the subtotals--BUT keep all the rows together that
belong with that subtotal. Is that possible??




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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com