ich habe eine Exceldatei mit sehr viel Code drinnen. Unter anderen werden makros ausgeführt beim Öffnen der Datei.
Nun habe ich versucht, ein Tabellenblatt ohne jegliche Formeln und VBA Code in eine neue Datei zu kopieren.
Dazu nachfolgender Code.
Private Sub CommandButton42_Click()
Dim DateVon As Date, DateBis As Date
Dim i&
If ComboBox1.Value = "" Or ComboBox2.Value = "" Then
MsgBox "Bitte Anfangdatum und/oder Enddatum festlegen"
Else
DateVon = CDate(ComboBox1.Value)
DateBis = CDate(ComboBox2.Value)
Worksheets("Aufstellung").Unprotect Password:="sp"
Worksheets("Lager BSK").Unprotect Password:="sp"
With ThisWorkbook.Worksheets("Aufstellung")
.Cells(2, 41) = "ACHTUNG: Neue Datensätze sind BLAU schattiert!"
.Cells(2, 41).Font.ColorIndex = 32
i = .Cells(.Rows.Count, 70).End(xlUp).Row
If i >= 16 Then
For i = 16 To i
If .Cells(i, 70).Value = _
DateVon Then
.Cells.EntireRow(i).Interior.Color = RGB(159, 182, 205)
Else
.Cells.EntireRow(i).Interior.ColorIndex = xlNone
End If
Next i
End If
End With
With ThisWorkbook.Worksheets("Lager BSK")
.Cells(2, 41) = "ACHTUNG: Neue Datensätze sind BLAU schattiert!"
.Cells(2, 41).Font.ColorIndex = 32
i = .Cells(.Rows.Count, 70).End(xlUp).Row
If i >= 16 Then
For i = 16 To i
If .Cells(i, 70).Value = _
DateVon Then
.Cells.EntireRow(i).Interior.Color = RGB(159, 182, 205)
Else
.Cells.EntireRow(i).Interior.ColorIndex = xlNone
End If
Next i
End If
End With
End If
Worksheets("Aufstellung").Protect Password:="sp"
Worksheets("Lager BSK").Protect Password:="sp"
End Sub
Aber mein Problem dabei ist, dass bilder nicht mitkopiert werden.Ich hätte auch probiert die Datei einfach insgesamt zu kopieren. Aber wenn ich dieses makro ausführe, wird die Datei erstellt und danach kommen Fehlermeldungen da in der neuen Datei die bezüge nicht mehr passen, da ich nur ein Tabellenblatt habe.
In erster Linie genau bei den Makros, die am Anfang beim start gestartet werden.
Hat hierzu jemand eine Idee?