@indianhp
with the great help of other forummembers (Nilem and AB33) in the link below. I was able to made this code for your sheet.
http://www.excelforum.com/excel-prog...50#post3285950
Sub integratie_Oeldere()
Dim wsTest As Worksheet
'check if sheet "ouput" 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", "Task", "Type", "Key Patient", "Key Doctor")
For Each sh In Sheets
With sh
If .Name <> "Consolidated" Then
Rng = .Cells(Rows.Count, 1).End(xlUp).Row - 1
If Rng > 0 Then
Sheets("Consolidated").Cells(Rows.Count, 1).End(xlUp)(2).Resize(Rng) = .Name
Sheets("Consolidated").Cells(Rows.Count, 2).End(xlUp)(2).Resize(Rng, 4) = .Range("A2").Resize(Rng, 4).Value
End If
End If
End With
Next
.Columns("A:Z").EntireColumn.AutoFit
End With
End Sub
Bookmarks