Hi
Does this help?
Sub aaa()
'this puts the hours onto the data sheet
Dim OutSH As Worksheet
Set OutSH = Sheets(1)
Application.ScreenUpdating = False
For j = 2 To Sheets.Count
Sheets(j).Activate
For Each ce In Range("D5:D" & WorksheetFunction.Max(5, Cells(Rows.Count, 4).End(xlUp).Row))
If Not IsEmpty(ce) Then
Set findit = Rows("4:4").Find(What:=ce.Value, LookAt:=xlPart, SearchOrder:=xlByRows)
If Not findit Is Nothing Then
Cells(ce.Row, findit.Column).Value = ce.Offset(0, 1).Value
Else
Cells(ce.Row, 27).Value = ce.Offset(0, 1).Value
End If
End If
Next ce
Next j
'this puts the hours onto the first sheet
For j = 2 To Sheets.Count
Sheets(j).Activate
For Each ce In Range("D5:D" & WorksheetFunction.Max(5, Cells(Rows.Count, 4).End(xlUp).Row))
If Not IsEmpty(ce) Then
Set findit = OutSH.Rows("4:4").Find(What:=ce.Value, LookAt:=xlPart, SearchOrder:=xlByRows)
If Not findit Is Nothing Then
OutSH.Cells(5, findit.Column).Value = OutSH.Cells(5, findit.Column).Value + ce.Offset(0, 1).Value
Else
OutSH.Cells(5, 27).Value = OutSH.Cells(5, 27).Value + ce.Offset(0, 1).Value
End If
End If
Next ce
Next j
Sheets(1).Activate
Application.ScreenUpdating = True
End Sub
rylo
Bookmarks