Thinkk I'm more confused now. Sorry.
This is my current code:
Option Explicit
Private Sub Worksheet_Activate()
Dim ws As Worksheet
Dim c As Object
Dim lastweek As Long
Me.Range("C4:J" & Rows.Count).ClearContents
For Each ws In Worksheets
If ws.Index > Sheets("Start").Index And ws.Index < Sheets("End").Index Then
Me.Range("C" & Rows.Count).End(xlUp).Offset(1, 0).Value _
= "=HYPERLINK(" & Chr(34) & Chr(91) & ThisWorkbook.Name & Chr(93) & Chr(39) & ws.Name & Chr(39) & "!A1" & Chr(34) & Chr(44) & Chr(34) & ws.Range("C4").Value & Chr(34) & ")"
If ws.Range("D8").Value <> "" Then
Me.Range("D" & Rows.Count).End(xlUp).Offset(1, 0).Value = "Ex-resident"
Else
Me.Range("D" & Rows.Count).End(xlUp).Offset(1, 0).Value _
= ws.Range("D5").Value
End If
Me.Range("E" & Rows.Count).End(xlUp).Offset(1, 0).Value _
= ws.Range("I3").Value
Me.Range("F" & Rows.Count).End(xlUp).Offset(1, 0).Value _
= ws.Range("I5").Value
Me.Range("G" & Rows.Count).End(xlUp).Offset(1, 0).Value _
= ws.Range("I7").Value
Me.Range("H" & Rows.Count).End(xlUp).Offset(1, 0).Value _
= Me.Range("F" & Rows.Count).End(xlUp) / Me.Range("E" & Rows.Count).End(xlUp)
Me.Range("I" & Rows.Count).End(xlUp).Offset(1, 0).Value _
= ws.Range("N5").Value
Me.Range("J" & Rows.Count).End(xlUp).Offset(1, 0).Value _
= ws.Range("N6").Value
End If
Next ws
Beep
End Sub
The above works fine. What i want to add in is when the 'For' loop is looping round the worksheets, i want it to do a second loop through the cells B31:B99 and look if any of the dates in this loop are in the last 7 days. If there are I want it to add the corresponding value in coulmn E to the total 'lastweek'. After moving through each of the worksheets. the total will then be written to cell N7.
FYI Column B contains dates and column E contains payments in £.
Thanks,
Mark
Bookmarks