Ik heb de macro die ik gevonden heb op http://www.rondebruin.nl/copy2.htm
een beetje aangepast.
Nog 1 probleempje: is het mogelijk om ervoor te zorgen dat ik via een keuzeformulier zoals in ASAP bestaat

kan beslissen hoeveel rijen er moeten gekopieerd worden.
Nu heb ik standaard in de macro 10 rijen voorzien (zie vet) en moet ik de macro veranderen indien er meer of minder rijen nodig zijn.
Noodoplossing zou zijn verschillende macro's naargelang het aantal rijen; maar keuzebox zou leuker zijn.
Aangepaste macro van http://www.rondebruin.nl/copy2.htm
Sub Rijen_10_samenvoegen()
' Sneltoets: CTRL+shift+z
Dim sh As Worksheet
Dim DestSh As Worksheet
Dim Last As Long
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'Delete the sheet "BrstZkje" if it exist
Application.DisplayAlerts = False
On Error Resume Next
ThisWorkbook.Worksheets("BrstZkje").Delete
On Error GoTo 0
Application.DisplayAlerts = True
'Add a worksheet with the name "BrstZkje"
Set DestSh = ThisWorkbook.Worksheets.Add
DestSh.Name = "BrstZkje"
'loop through all worksheets and copy the data to the DestSh
For Each sh In Worksheets(Array("Klas1", "Klas3"))
If sh.Name <> DestSh.Name Then
Last = LastRow(DestSh)
'This example copies everything, if you only want to copy
'values/formats look at the example below this macro
sh.Range("A1:Z10").Copy DestSh.Cells(Last + 1, "A")
End If
Next
Application.Goto DestSh.Cells(1)
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
_________________________________________________________________
Function LastRow(sh As Worksheet)
On Error Resume Next
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 Resume Next
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
een beetje aangepast.
Nog 1 probleempje: is het mogelijk om ervoor te zorgen dat ik via een keuzeformulier zoals in ASAP bestaat

kan beslissen hoeveel rijen er moeten gekopieerd worden.
Nu heb ik standaard in de macro 10 rijen voorzien (zie vet) en moet ik de macro veranderen indien er meer of minder rijen nodig zijn.
Noodoplossing zou zijn verschillende macro's naargelang het aantal rijen; maar keuzebox zou leuker zijn.
Aangepaste macro van http://www.rondebruin.nl/copy2.htm
Sub Rijen_10_samenvoegen()
' Sneltoets: CTRL+shift+z
Dim sh As Worksheet
Dim DestSh As Worksheet
Dim Last As Long
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
'Delete the sheet "BrstZkje" if it exist
Application.DisplayAlerts = False
On Error Resume Next
ThisWorkbook.Worksheets("BrstZkje").Delete
On Error GoTo 0
Application.DisplayAlerts = True
'Add a worksheet with the name "BrstZkje"
Set DestSh = ThisWorkbook.Worksheets.Add
DestSh.Name = "BrstZkje"
'loop through all worksheets and copy the data to the DestSh
For Each sh In Worksheets(Array("Klas1", "Klas3"))
If sh.Name <> DestSh.Name Then
Last = LastRow(DestSh)
'This example copies everything, if you only want to copy
'values/formats look at the example below this macro
sh.Range("A1:Z10").Copy DestSh.Cells(Last + 1, "A")
End If
Next
Application.Goto DestSh.Cells(1)
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub
_________________________________________________________________
Function LastRow(sh As Worksheet)
On Error Resume Next
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 Resume Next
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