Thread: Weekly Totals
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Tredown Tredown is offline
external usenet poster
 
Posts: 15
Default Weekly Totals

I have a data sheet which is populated from a form on another worksheet by
means of command button. What i would like to do is to add something to the
button code to automaticaly add a total row at the end of every week to the
data sheet.
This is the code use to populate the data sheet
Sub Button1_Click()
Dim smallrng As Range, DestRange As Range
Dim DestSheet As Worksheet, Lr As Long
Dim SourceRange As Range, I As Integer

With Application
.ScreenUpdating = False
.EnableEvents = False
End With

'fill in the Source Sheet and range
Set SourceRange =
Sheets("Sheet1").Range("H2,E5,E6,E7,E8,E9,E10,E11, E12,E13,E14,E15")

'Fill in the destination sheet and call the LastRow
'function to find the last row
Set DestSheet = Sheets("Sheet2")
Lr = LastRow(DestSheet)
I = 1

For Each smallrng In SourceRange.Areas

'We make DestRange the same size as smallrng and use the
'Value property to give DestRange the same values
With smallrng
Set DestRange = DestSheet.Cells(Lr + 1, I) _
.Resize(.Rows.Count, .Columns.Count)
End With
DestRange.Value = smallrng.Value
I = I + smallrng.Columns.Count

Next smallrng

With Application
.ScreenUpdating = True
.EnableEvents = True
End With
Range("C5:D15,C18:D27").Select
Selection.ClearContents
End Sub
Any help would be much appreciated
Thanks
Tredown