Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Subtotal macro and delete original data

I am trying to subtotal the following data:

Location ProductID Qty
1 2a 5
1 2a 2
1 2a 10
32 4bc 1
32 4bc 4
32 r3s 8


I want the end result to look like this (I do not want the word "subtotal"
anywhere on my worksheet):
Location ProductID Qty
1 2a 17
32 4bc 5
32 r3s 8

and delete the original data rows so the subtotaled rows are the only rows
in the worksheet.
(I am using Excel 2003 and need all the rows I can get)

Any help is greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Subtotal macro and delete original data

If I only had to do this once, I'd do the data|subtotal stuff
Then hide the details and copy the visible rows to a new worksheet and paste as
values

Then do an edit|replace to replace the Total (or Average or....) with (nothing).

If I had to do this lots of times, I'd learn about Data|pivottable.

Then convert that pivottable to values (select it, copy|pastespecial|values)

And if I had to do it lots and lots of times, I'd record a macro when I did the
pivottable stuff.


If you've never used pivottables, here are a few links:

Debra Dalgleish's pictures at Jon Peltier's site:
http://peltiertech.com/Excel/Pivots/pivottables.htm
And Debra's own site:
http://www.contextures.com/xlPivot01.html

John Walkenbach also has some at:
http://j-walk.com/ss/excel/files/general.htm
(look for Tony Gwynn's Hit Database)

Chip Pearson keeps Harald Staff's notes at:
http://www.cpearson.com/excel/pivots.htm

MS has some at (xl2000 and xl2002):
http://office.microsoft.com/downloads/2000/XCrtPiv.aspx
http://office.microsoft.com/assistan...lconPT101.aspx

ExcelNovice wrote:

I am trying to subtotal the following data:

Location ProductID Qty
1 2a 5
1 2a 2
1 2a 10
32 4bc 1
32 4bc 4
32 r3s 8

I want the end result to look like this (I do not want the word "subtotal"
anywhere on my worksheet):
Location ProductID Qty
1 2a 17
32 4bc 5
32 r3s 8

and delete the original data rows so the subtotaled rows are the only rows
in the worksheet.
(I am using Excel 2003 and need all the rows I can get)

Any help is greatly appreciated.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Subtotal macro and delete original data

Sub combinerows()

RowCount = 1
Do While Range("A" & RowCount) < ""
If Range("A" & RowCount) = _
Range("A" & (RowCount + 1)) And _
Range("B" & RowCount) = _
Range("B" & (RowCount + 1)) Then

Range("C" & RowCount) = _
Range("C" & RowCount) + _
Range("C" & (RowCount + 1))

Rows(RowCount + 1).Delete
Else
RowCount = RowCount + 1
End If
Loop
End Sub


"ExcelNovice" wrote:

I am trying to subtotal the following data:

Location ProductID Qty
1 2a 5
1 2a 2
1 2a 10
32 4bc 1
32 4bc 4
32 r3s 8


I want the end result to look like this (I do not want the word "subtotal"
anywhere on my worksheet):
Location ProductID Qty
1 2a 17
32 4bc 5
32 r3s 8

and delete the original data rows so the subtotaled rows are the only rows
in the worksheet.
(I am using Excel 2003 and need all the rows I can get)

Any help is greatly appreciated.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Subtotal macro and delete original data

Try recording a macro while applying subtotals to your data.
I did and got this (header in row 5) ...
'--
Selection.Subtotal GroupBy:=2, Function:=xlSum, TotalList:=Array(3), _
Replace:=True, PageBreaks:=False, SummaryBelowData:=True
ActiveSheet.Outline.ShowLevels RowLevels:=2
Rows("15:15").Select
Selection.Delete Shift:=xlUp
Range("B5").Select
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware
(Excel Add-ins / Excel Programming)




"ExcelNovice"
wrote in message
I am trying to subtotal the following data:

Location ProductID Qty
1 2a 5
1 2a 2
1 2a 10
32 4bc 1
32 4bc 4
32 r3s 8
I want the end result to look like this (I do not want the word "subtotal"
anywhere on my worksheet):
Location ProductID Qty
1 2a 17
32 4bc 5
32 r3s 8
and delete the original data rows so the subtotaled rows are the only rows
in the worksheet.
(I am using Excel 2003 and need all the rows I can get)
Any help is greatly appreciated.
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
Delete duplicate and original row JStiehl Excel Discussion (Misc queries) 3 June 30th 09 12:50 PM
Combine two columns and delete original like to know Excel Discussion (Misc queries) 1 July 4th 08 06:46 PM
macro save as delete original file Pam M Excel Programming 2 September 25th 07 08:24 PM
Updating original data from vlookup screen (macro?) Gavin Williams Excel Programming 0 April 22nd 07 06:34 PM
save original data after macro is run again MINAL ZUNKE New Users to Excel 3 July 7th 05 12:48 PM


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