Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 15th, 2013, 06:23 PM
Registered User
 
Join Date: Aug 2012
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sum amount based on same reference id

Hi,

If I have a excel 2003 file with a few rows/columns as follows

1234B,AB900,1
1234B,AB900,1
1244A,AB901,1
1267B,AB906,2
1279B,AB915,1
1279B,AB915,3
1279B,AB915,1
1288A,AB922,2

Is it possible to create a new line below each group of id and enter the total of column C using VBA

example:


1234B,AB900,1
1234B,AB900,1
2
1244A,AB901,1
1
1267B,AB906,2
2
1279B,AB915,1
1279B,AB915,3
1279B,AB915,1
4
1288A,AB922,2
2



Thanks for any help,

David
 
Old March 3rd, 2013, 10:20 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

You can use the SubTotal function of Excel to achieve this


Code:
    ActiveSheet.UsedRange.Subtotal GroupBy:=1, Function:=xlSum, TotalList:=Array(3), _
        Replace:=True, PageBreaks:=False, SummaryBelowData:=True
Please tweak the above to suit your needs

Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Re-position data and sum quantity based on matching reference djfscouse Excel VBA 1 March 3rd, 2013 10:23 PM
muenchian sum based on multiple grouping chopstix21 XSLT 1 November 2nd, 2012 10:28 AM
generate-id() cross-reference kaiLa XSLT 5 June 7th, 2010 12:55 PM
sum group values based on cell criteria darkdestroyer Excel VBA 1 January 9th, 2008 09:13 PM
Jumping to specific record in FormView based on ID peter0480 ASP.NET 2.0 Basics 5 June 18th, 2007 04:37 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.