#1   Report Post  
Old July 5th 07, 06:30 AM posted to microsoft.public.excel.misc
external usenet poster
 
First recorded activity by ExcelBanter: Jul 2006
Posts: 51
Default Summary using VBA

ORDER DATA
Order # Part# Qty
1 A11 3
2 A12 4
3 A11 1
4 A12 2
5 A11 3
6 A11 1
7 A11 2
8 A13 2
9 A11 3
10 A12 4

I have order Order #, Part # and Qty in Col A,B, C in Tab-A
I want USING VBA a summary as under in TAb-2. I am aware this can achieved
vy PIVOT, SUBTOTALS etc.

ORDER SUMMARY
Part# Qty
A11 13
A12 10
A13 2
Grand Total 25



  #2   Report Post  
Old July 5th 07, 08:36 AM posted to microsoft.public.excel.misc
external usenet poster
 
First recorded activity by ExcelBanter: Jul 2006
Posts: 10,594
Default Summary using VBA

Public Sub ProcessData()
Const TEST_COLUMN As String = "A" '<=== change to suit
Dim i As Long
Dim j As Long
Dim iRow As Long
Dim iLastRow As Long

With ActiveSheet

.Range("B1:C1").Copy Worksheets("Sheet2").Range("A1")
iLastRow = .Cells(.Rows.Count, TEST_COLUMN).End(xlUp).Row
j = 2
For i = 2 To iLastRow
iRow = 0
On Error Resume Next
iRow = Application.Match(.Cells(i, "B"), _
Worksheets("Sheet2").Columns(1), 0)
On Error GoTo 0
If iRow = 0 Then
Worksheets("Sheet2").Cells(j, "A").Value = _
.Cells(i, "B").Value
Worksheets("Sheet2").Cells(j, "B").Value = _
.Cells(i, "C").Value
j = j + 1
Else
Worksheets("Sheet2").Cells(iRow, "B").Value = _
Worksheets("Sheet2").Cells(iRow, "B").Value + _
.Cells(i, "C").Value
End If
Next i

Worksheets("Sheet2").Cells(j, "A").Value = "Grand Total"
Worksheets("Sheet2").Cells(j, "B").FormulaR1C1 = "=SUM(R2C:R[-1]C)"
End With

End Sub


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Ananth" wrote in message
...
ORDER DATA
Order # Part# Qty
1 A11 3
2 A12 4
3 A11 1
4 A12 2
5 A11 3
6 A11 1
7 A11 2
8 A13 2
9 A11 3
10 A12 4

I have order Order #, Part # and Qty in Col A,B, C in Tab-A
I want USING VBA a summary as under in TAb-2. I am aware this can achieved
vy PIVOT, SUBTOTALS etc.

ORDER SUMMARY
Part# Qty
A11 13
A12 10
A13 2
Grand Total 25






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
Summary SUM Ananth Excel Discussion (Misc queries) 5 March 13th 07 11:43 AM
Summary Dale Excel Worksheet Functions 7 February 20th 07 10:26 PM
multi group with summary above with 1 overall summary line below Freddy Excel Discussion (Misc queries) 2 November 7th 05 03:30 PM
multi group with summary above with 1 overall summary line below Freddy Excel Discussion (Misc queries) 1 November 1st 05 08:50 PM
Summary [email protected] Excel Worksheet Functions 2 February 2nd 05 05:46 AM


All times are GMT +1. The time now is 03:50 AM.

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

About Us

"It's about Microsoft Excel"

 

Copyright © 2017