Tabelle kopieren in andere Datei
06.09.2023 12:45:21
Pitt
Er kopiert mir Daten von Depot ins Depot1.
Dies soll aber anders rumsein.
Dim wsDepot As Worksheet
Dim wsZiel As Worksheet
Dim ILetzteReiheDepot As Long
Dim ILetzteReiheZiel As Long
Set wsDepot = Workbooks("Depot.xlsm").Worksheets("Depotbestand")
'ZielDatei
Dim wbZiel As Workbook
Set wbZiel = Workbooks("Depot1.xlsm")
Set wsZiel = wbZiel.Worksheets("Depotbestand")
'Set wsZiel = Workbooks("Depot1.xlsm").Worksheets("Depotbestand")
'die letzte Reihe der neuen Daten finden
ILetzteReiheDepot = wsDepot.Cells(wsDepot.Rows.Count, "A").End(xlUp).Row
'letzte Reihe der Daten finden und 2 Zellen Luft lassen
ILetzteReiheZiel = wsZiel.Cells(wsZiel.Rows.Count, "A").End(xlUp).Offset(3).Row
'Daten kopieren
wsDepot.Range("A1:N" & ILetzteReiheDepot).Copy _
wsZiel.Range("A" & ILetzteReiheZiel)
End Sub
Das gelingt mir aber nicht wirklich.
Das Makro soll von Depot1 gestartet werden, nicht von Depot.
So sieht meins aus. Beide dateien sind auf.
Sub Kopieren_Zellen_vom_letztenWert()
Dim wsDepot1 As Worksheet
Dim wsZiel As Worksheet
Dim ILetzteReiheDepot As Long
Dim ILetzteReiheZiel As Long
Set wsDepot1 = Workbooks("Depot1.xlsm").Worksheets("Depotbestand")
'ZielDatei
Dim wbZiel As Workbook
Set wbZiel = Workbooks("Depot1.xlsm")
Set wsZiel = wbZiel.Worksheets("Depotbestand")
'Set wsZiel = Workbooks("Depot1.xlsm").Worksheets("Depotbestand")
'die letzte Reihe der neuen Daten finden
ILetzteReiheDepot = wsDepot1.Cells(wsDepot1.Rows.Count, "A").End(xlUp).Row
'letzte Reihe der Daten finden und 2 Zellen Luft lassen
ILetzteReiheZiel = wsZiel.Cells(wsZiel.Rows.Count, "A").End(xlUp).Offset(3).Row
'Daten kopieren
wsDepot1.Range("A1:N" & ILetzteReiheDepot).Copy _
wsZiel.Range("A" & ILetzteReiheZiel)
Wo liegt der Fehler bei mir?
Danke
Gruß
Pitt
Anzeige