- De macro voegt een blad met de naam Master toe aan uw werkmap en kopieert de cellen van elk blad in uw werkmap in dit werkblad.
- De eerste macro maakt een normale kopie en de tweede macro kopieert de waarden.
- De subs van de macro gebruiken onderstaande functies, de macro's werken niet zonder de functies.
Sub CopyFromRow() Dim sh As Worksheet Dim DestSh As Worksheet Dim shLast As Long Dim Last As Long If SheetExists("Master") = True Dan MsgBox "The sheet Master bestaat al" Exit Sub End If Application.ScreenUpdating = False Set DestSh = Worksheets.Add DestSh.Name = "Master" voor elke sh in ThisWorkbook.Worksheets If sh.Name DestSh.Name Dan If sh.UsedRange.Count > 1 Then Last = LastRow(DestSh) shLast = LastRow(sh) sh.Range( sh.Rows(3), sh.Rows(shLast)).Copy DestSh.Cells(Last + 1, 1) End If End If Next Application.ScreenUpdating = True End Sub Sub CopyFromRowValues() Dim sh As-werkblad Dim DestSh As-werkblad Dim shLast As Long Dim Last As Long If SheetExists ("Master") = True Dan MsgBox "The sheet Master bestaat al" Exit Sub End If Application.ScreenUpdating = False Set DestSh = Worksheets.Add DestSh.Name = "Master" For Each sh In ThisWorkbook.Worksheets If sh.Name DestSh.Name Then If sh.UsedRange.Count > 1 Then Last = LastRow(DestSh) shLast = LastRow(sh) With sh.Range(sh.Rows(3), sh.Rows(shLast)) DestSh.Cells(Last + 1, 1).Resize(.Rows.Count, _ .Columns.Count).Value = .Value End With End If End If Next Application.ScreenUpdating = True End Sub Functie LastRow(sh As Worksheet) On Error Hervat Volgende LastRow = sh.Cells.Find(What:="*", _ After:=sh.Range("A1"), _ Lookat:=xlPart, _ LookIn:=xlFormulas , _ SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Row On Error GoTo 0 End Function Function Lastcol(sh As Worksheet) On Error Hervatten Volgende Lastcol = sh.Cells.Find(What:=" *", _ After:=sh.Range("A1"), _ Lookat:=xlPart, _ LookIn:=xlFormulas, _ SearchOrder:=xlByColumns, _ SearchDirection:=xlPrevious, _ MatchCase:=False).Column On Error GoTo 0 End Function Function SheetExists(SName As String, _Optioneel ByVal WB As Workbook) As Boolean On Error Hervat volgende Als WB niets is, stel dan WB = ThisWorkbook SheetExists = CBool(Len(Sheets(SName).Name)) in.