Ok, you will need to provide on the sheets the required Team Assignments, so I added that in column H. Just list the teams you want listed on each sheet in column H and they will be included.
Also, since you have both static cells at the bottom and a dynamic number of rows to be copied in, I'm recommending you flip/flop your layout so the expanding stuff is at the bottom starting in row 10, now nothing below it to run into. The macro will clear everything from row 11 down and add new info each time it is run.
Option Explicit
Sub RateSheets()
Dim MyArr As Variant, LR As Long
Dim ws As Worksheet, wsAsgn As Worksheet
Set wsAsgn = ActiveWorkbook.Sheets("Assignments")
For Each ws In ActiveWorkbook.Worksheets
If ws.Name <> wsAsgn.Name Then
With ws
MyArr = Application.WorksheetFunction.Transpose(ws.Range("H:H").SpecialCells(xlConstants))
wsAsgn.Range("A1").CurrentRegion.AutoFilter Field:=3, Criteria1:=MyArr, Operator:=xlFilterValues
LR = wsAsgn.Range("A" & Rows.Count).End(xlUp).Row
If LR > 1 Then
ws.UsedRange.Offset(10).Clear
wsAsgn.Range("A2:D" & LR).Copy ws.Range("A11")
LR = ws.Range("A" & Rows.Count).End(xlUp).Row
With ws.Range("C" & LR + 1)
.Value = "TOTAL PAY:"
.Interior.ColorIndex = 15
.Font.Bold = True
End With
With ws.Range("D" & LR + 1)
.FormulaR1C1 = "=SUM(R11C:R[-1]C)"
.Interior.ColorIndex = 15
.Font.Bold = True
.NumberFormat = "$0.00"
End With
End If
End With
End If
Next ws
End Sub
How/Where to install the macro:
1. Open up your workbook
2. Get into VB Editor (Press Alt+F11)
3. Insert a new module (Insert > Module)
4. Copy and Paste in your code (given above)
5. Get out of VBA (Press Alt+Q)
6. Save as a macro-enabled workbook
The macro is installed and ready to use. Press Alt-F8 and select RateSheets from the macro list.
Bookmarks