Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA-Add Column Totals

I have a series of reports I would like to know VBA code
to add totals to the columns as part of code that displays
a range in print preview mode. But then needs to
be "cleared" when closing, so that additional records
(rows of data) can be added via data form. Can anyone
assist? Thanks, Chris
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA-Add Column Totals

set rng = ActiveSheet.UsedRange
set rng = rng.rows(rng.rows.count).offset(1,0).Cells
rng.FormulaR1C1 = "=Sum(R[-1]C:R1C)"
ActiveSheet.Printout
rng.EntireRow.Delete

--
Regards,
Tom Ogilvy

"Chris Linger" wrote in message
...
I have a series of reports I would like to know VBA code
to add totals to the columns as part of code that displays
a range in print preview mode. But then needs to
be "cleared" when closing, so that additional records
(rows of data) can be added via data form. Can anyone
assist? Thanks, Chris



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA-Add Column Totals

Chris,

I hope the following helps. It assumes you want to total colunn a.
You can make changes to suit your needs.

Sub add_column()
Application.ScreenUpdating = False
Dim irng As Range
Dim firstcell, lastcell
Set irng = Worksheets("sheet2").Cells(1, 1).CurrentRegion
lastrow = Range("a1").End(xlDown).Select
firstcell = "A1"
lastcell = ActiveCell.Row
TheFormula = "=sum(" & firstcell & ":" & "A" & lastcell & ")"
ActiveCell.Offset(1, 0).Value = TheFormula
ActiveWindow.SelectedSheets.PrintPreview
Selection.Offset(1, 0).ClearContents
End Sub

Charle

--
Message posted from http://www.ExcelForum.com

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
Pivot Totals: Group totals different from Grand totals PsyberFox Excel Discussion (Misc queries) 1 February 13th 08 06:16 PM
sum column totals Faw1001 New Users to Excel 1 September 22nd 05 12:31 PM
column totals Scudo New Users to Excel 4 May 28th 05 10:50 AM
Calculating totals in a column based on a lookup in another column Michael Wright via OfficeKB.com Excel Worksheet Functions 1 April 15th 05 09:52 AM
Comparing/matching totals in a column to totals in a row Nicole L. Excel Worksheet Functions 3 January 27th 05 10:42 PM


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

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

About Us

"It's about Microsoft Excel"