View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dan R. Dan R. is offline
external usenet poster
 
Posts: 220
Default adding daily totals to weekly totals

Assuming all of your headers are in the first row...

Sub dailyTotals()
Dim dtRng As Range, lCol As Long, lRow As Long
Dim rng As Range, found As Range
With Sheets("WEEKLY DATA")
lCol = .Range("IV1").End(xlToLeft).Column
Set dtRng = .Range(.Cells(1, 1), .Cells(1, lCol))
End With
With Sheets("daily data")
lRow = .Range("B65536").End(xlUp).Row
Set rng = .Range(.Cells(2, 2), .Cells(lRow, 2))
End With
Set found = dtRng.Find( _
Right(Sheets("daily data").Range("B1"), 8), _
LookIn:=xlValues)
If Not found Is Nothing Then
rng.Copy found.Offset(1, 0)
Else
MsgBox "Date wasn't found."
End If
End Sub

--
Dan

On Mar 28, 6:41*am, wrote:
I have a spreadsheet called daily data *it has two columns of data, at
the end of the day I want to copy the values in column b and paste
them to the spreadsheet weekly data. *Each column in weekly data has
values grouped in week ending columns i.e

daily data

DATE = 28/03/08

DATA1 * 10
DATA2 * 20
DATA3 * 20

WEEKLY DATA

* * * * * * * *WK ENDING 28/03/07 * * * * * *WK ENDING 05/04/2008
DATA1 * * * * * * * * 30
60
DATA2 * * * * * * * * 45
60
DATA3 * * * * * * * * 35
60

I need some code that can work out which week ending column to add the
daily totals too, any help greatly recieved

John