I ran the macro below.
See the attached file.
Sub integratie_Oeldere_revisted_vs3()
'I got a lot of help from AB33, to get this code working; thanks for that AB33.
Dim wsTest As Worksheet
'check if sheet "Consolidated" already exist
Const strSheetName As String = "Consolidated"
Set wsTest = Nothing
On Error Resume Next
Set wsTest = ActiveWorkbook.Worksheets(strSheetName)
On Error GoTo 0
If wsTest Is Nothing Then
Worksheets.Add.Name = strSheetName
End If
With Sheets("Consolidated")
.UsedRange.ClearContents
.Range("A1:E1").Value = Array("sheet", "CODE", "HRS", "RATE", "AMOUNT")
For Each Sh In Sheets
With Sh
If .Name <> "Consolidated" Then
LR = .Cells(.Rows.Count, 9).End(xlUp).Row
If LR >= 2 Then
Rng = .Cells.Find("*", , , , xlByRows, xlPrevious).Row - 1
NR = Sheets("Consolidated").Cells.Find("*", , , , xlByRows, xlPrevious).Row + 1
If Rng > 0 Then
Sheets("Consolidated").Cells(NR, 1).Resize(Rng) = .Name
Sheets("Consolidated").Cells(NR, 2).Resize(Rng, 4) = .Range("I4").Resize(Rng, 4).Value
End If
End If
End If
End With
Next
On Error Resume Next
.Range("e2:e" & .Rows.Count).SpecialCells(4).EntireRow.Delete
.Columns("A:Z").EntireColumn.AutoFit
End With
End Sub
Bookmarks