Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Pivot Totals: Group totals different from Grand totals | Excel Discussion (Misc queries) | |||
sum column totals | New Users to Excel | |||
column totals | New Users to Excel | |||
Calculating totals in a column based on a lookup in another column | Excel Worksheet Functions | |||
Comparing/matching totals in a column to totals in a row | Excel Worksheet Functions |