Hallo,
hier mal ein Auszug/ Beispiel wie ich das Damals gelöst habe:
Sub PM_Kopieren_Macro()
Debug.Print Now
Dim wsCopy As Worksheet
Dim wsDest As Worksheet
Dim lCopyLastRow As Long
Dim lDestLastRow As Long
Dim myRange As Range
Dim WsF As WorksheetFunction
'Set variables for copy and destination sheets
Set wsCopy = Workbooks(datei.xlsx).Worksheets("sheet")
Set wsDest = Workbooks("PM_KE_Master.xlsm").Worksheets("master")
'1. Find last used row in the copy range based on data in column A
lCopyLastRow = wsCopy.Cells(wsCopy.Rows.Count, "A").End(xlUp).Row
'2. Find first blank row in the destination range based on data in column A
'Offset property moves down 1 row
lDestLastRow = wsDest.Cells(wsDest.Rows.Count, "N").End(xlUp).Offset(1).Row
'3. Copy & Paste Data
wsCopy.Range("A2:A" & lCopyLastRow).Copy _
wsDest.Range("N" & lDestLastRow)
wsCopy.Range("B2:B" & lCopyLastRow).Copy _
wsDest.Range("O" & lDestLastRow)
wsCopy.Range("D2:D" & lCopyLastRow).Copy _
wsDest.Range("P" & lDestLastRow)
wsCopy.Range("E2:E" & lCopyLastRow).Copy _
wsDest.Range("Q" & lDestLastRow)
wsCopy.Range("F2:F" & lCopyLastRow).Copy _
wsDest.Range("R" & lDestLastRow)
wsCopy.Range("G2:G" & lCopyLastRow).Copy _
wsDest.Range("S" & lDestLastRow)
wsCopy.Range("H2:H" & lCopyLastRow).Copy _
wsDest.Range("T" & lDestLastRow)
wsCopy.Range("I2:I" & lCopyLastRow).Copy _
wsDest.Range("U" & lDestLastRow)
wsCopy.Range("J2:J" & lCopyLastRow).Copy _
wsDest.Range("V" & lDestLastRow)
wsCopy.Range("K2:K" & lCopyLastRow).Copy _
wsDest.Range("W" & lDestLastRow)
wsCopy.Range("M2:M" & lCopyLastRow).Copy _
wsDest.Range("X" & lDestLastRow)
wsCopy.Range("N2:N" & lCopyLastRow).Copy _
wsDest.Range("Y" & lDestLastRow)
'wsDest.Cells.ClearFormats
wsDest.Range("A2:AH60000").ClearFormats
Debug.Print Now
End Sub
Hoffe das hilft dir weiter!
|