ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Sort, Subtotal, Label Subtotal, Insert row (https://www.excelbanter.com/excel-programming/294543-sort-subtotal-label-subtotal-insert-row.html)

Teak

Sort, Subtotal, Label Subtotal, Insert row
 
I have 4 columns. Need to do following:-

- sort by columns A, B, C in ascending order.
- subtotal on change of column C
- change subtotal text to "Subtotal for Sto XXX" where XXX is column C
- insert a line after each subtotal for easy reading
- insert grand total at end.

I think this may sound easy for most of you. But I'm novice. Plse help.
Thanks.



Frank Kabel

Sort, Subtotal, Label Subtotal, Insert row
 
Hi
as a starting point I'd suggest you record a macro ('Tools - Macros -
Record') and do this manually while recording this macro. After this
have a look at the resulting code 8or post back with some questions).

You may also take a look at
http://www.mvps.org/dmcritchie/excel/getstarted.htm

--
Regards
Frank Kabel
Frankfurt, Germany

"Teak" schrieb im Newsbeitrag
...
I have 4 columns. Need to do following:-

- sort by columns A, B, C in ascending order.
- subtotal on change of column C
- change subtotal text to "Subtotal for Sto XXX" where XXX is

column C
- insert a line after each subtotal for easy reading
- insert grand total at end.

I think this may sound easy for most of you. But I'm novice. Plse

help.
Thanks.




No Name

Sort, Subtotal, Label Subtotal, Insert row
 
Unfortunately, it's not that easy to work with
subtotals. But I can give you a few hints to get started.

You can use the Excel subtotal funtion to get started.

.Range("A2").Subtotal GroupBy:=iColCount, _
Function:=xlCount, TotalList:=Array(3), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True

Then you need to loop through all the rows to find
subtotals

iRowCount = ws.Range("A1").CurrentRegion.Rows.Count
For i = 2 To iRowCount
If Rows(i).OutlineLevel <= 2 Then
ADD WHAT YOU NEED TO DO HERE
Next i

Diane


-----Original Message-----
I have 4 columns. Need to do following:-

- sort by columns A, B, C in ascending order.
- subtotal on change of column C
- change subtotal text to "Subtotal for Sto XXX"

where XXX is column C
- insert a line after each subtotal for easy reading
- insert grand total at end.

I think this may sound easy for most of you. But I'm

novice. Plse help.
Thanks.


.



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

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