Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add up totals with VBA on excel spreadsheet

Status
Not open for further replies.

thomasks

Programmer
May 12, 2006
113
US
I have data in an excel spreadsheet that I need to run a cumulative total on a column, until I reach an amount. Then insert a couple of blank lines with the sum of the calculated rows. Then proceed to do the same for the remaining rows on the sheet.
The sheet is data for motors, and I want to seperate the data so that the cumulative total of column "P" (Full load amps for each motor)for discussions sake is no more than 20 amps. Once I reach 20 amps for a series of rows, I need to insert a couple of blank lines and put the total of "20 amps" in one of the blank lines. Then do the same thing repeating until I reach the end of the worksheet.
Can anyone give me some example code to run in VBA to accomplish this? All help is appreciated.
 
Hmmm.. this is an interesting question. Just off the top of my head, it sounds like you need some code to run during either the "Detail_Print" or "Detail_Format" event of your report that evaluates the amp guy, and depending on situation, insert a footer section and print some stuff in it...

This doesn't sound like the kind of thing that can be calculated ahead of time with a query very easily..it's a 'run-time' process.

What you need is the algorithm for determining the exact situation that will require the process to break at, and the method used to evaluate and decide when to do it..for example, do you break when AMPS = 20, or when >= 20 or when the NEXT printed row will be >= 20 or what?

IOW, "12 amps....5 amps...4 amps... BREAK! or "12 Amps...5 amps...4 Amps.. OOPS! OVER 20!! Backup and print only the 12 amps...5 amps lines... then start with "4 amps....

Could be fun...




--------------------------------------
"For a successful technology, reality must take precedence over public relations, for Nature cannot be fooled." - Richard P. Feynman
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top