Ik gebruik de volgende VB code:
**********************************************
*********************************************
Nu wil ik dit op meerdere sheets gebruiken, en dan moet excel altijd de actieve sheet als source gebruiken. Hoe doe ik dat ?
**********************************************
Code:
Sub CopySignificant()
Dim DestSheet As Worksheet
Set DestSheet = Worksheets("Bestelformulier")
Dim sRow As Long 'row index on source worksheet
Dim dRow As Long 'row index on destination worksheet
Dim sCount As Long
sCount = 1
dRow = 20
If ActiveSheet.FilterMode Then
ActiveSheet.ShowAllData
End If
'sRow = Range("D65536").End(xlUp).Row
For sRow = 7 To Range("D65536").End(xlUp).Row
If Cells(sRow, "A") <> "" Then
sCount = sCount + 1
dRow = dRow
'copy cols A,F,E & D
DestSheet.Rows(dRow + 1).Rows.Insert
Cells(sRow, "K").Copy Destination:=DestSheet.Cells(dRow + 1, "A")
Cells(sRow, "C").Copy Destination:=DestSheet.Cells(dRow + 1, "B")
Cells(sRow, "D").Copy Destination:=DestSheet.Cells(dRow + 1, "C")
Cells(sRow, "E").Copy Destination:=DestSheet.Cells(dRow + 1, "D")
Cells(sRow, "F").Copy Destination:=DestSheet.Cells(dRow + 1, "E")
Cells(sRow, "A").Copy Destination:=DestSheet.Cells(dRow + 1, "F")
Cells(1, "C").Copy Destination:=DestSheet.Cells(dRow + 1, "G")
Cells(1, "D").Copy Destination:=DestSheet.Cells(dRow + 1, "H")
Cells(sRow, "A").Clear
End If
Next sRow
MsgBox sCount - 1 & " Artikelen naar de order gekopieerd", vbInformation, "Transfer Done"
End Sub
Nu wil ik dit op meerdere sheets gebruiken, en dan moet excel altijd de actieve sheet als source gebruiken. Hoe doe ik dat ?
Laatst bewerkt: