dedalus2011
Goto Top

Vba Speichern eines neuen Workbooks mit .PasteSpecial xlPasteFormulas

Beim Speichern eines neuen Workbooks mit .PasteSpecial xlPasteFormulas bleiben Verweise auf die ursprüngliche Datei drin

Hallo,

beim Speichern eines neuen Workbooks ("Newbook") bleibt der Verweis auf den alten Tabellenblatt in der Formelinhalt drin und es wird nicht aktualisiert. Die Zellen enthalten folgende Formeln =IF('[Auswerte_Makro.xls]Tabelle zum Import '!G5="";"";'[Auswerte_Makro.xls]Tabelle zum Import Motivdata'!G5)

Ich habe bisher folgendes probiert

Set Newbook = Workbooks.Add
    Dim wksheet As Worksheet
     
For i = 1 To ThisWorkbook.Sheets.Count
   ThisWorkbook.Worksheets(i).Cells.Copy
   With Newbook.Sheets(i).Range("A1")  
     .PasteSpecial xlPasteFormulas
    
End With
   Next

Newbook.SaveAs Filename:=Pfad & "\" & Filename & ".xls"  

......


der Verweis auf die alte Datei ("Auswerte_Makro.xls") bleibt aber drin. Es klappt nur wenn das komplette Workbook gespeichert wird, Gibt's da Workarounds?

Grüße

dedalus2011

Content-Key: 184011

Url: https://administrator.de/contentid/184011

Printed on: April 19, 2024 at 22:04 o'clock

Mitglied: 76109
76109 Apr 24, 2012 at 10:34:38 (UTC)
Goto Top
Hallo dedalus2011!

Versuchs mal so:
    Dim SheetsArray As Variant, i As Integer
    
    ReDim SheetsArray(1 To Sheets.Count)
    
    For i = 1 To Sheets.Count
        SheetsArray(i) = i
    Next
    
    Sheets(SheetsArray).Copy
    
    ActiveWorkbook.Close SaveChanges:=True, Filename:=Pfad & "\" & Filename & ".xls"  

Gruß Dieter