Ich will alle markierten Sheets in ein neues Workbook speichern und das gleich schliessen.
das von mir funktioniert leider nicht.
Private Sub Speichern_Click()
'Workbook speichern
Dim Pfad As String
Dim Name As String
Dim sh As Worksheet
Dim WBspeichern As String
Pfad = "f:\Prüfprotokoll\Linux\Test\"
Name = Range("AB1").Value & "_" & Range("B2").Value & "_" & Range("V3").Value & "_" & Range("F3").Value & ".xls"
WBspeichern = Pfad & Name
Application.DisplayAlerts = False
Dim shArray As Variant
Dim ix As Integer
ReDim shArray(ActiveWorkbook.Sheets.Count)
ix = 0
For Each sh In ActiveWorkbook.Sheets
If sh.Visible = True Then
shArray(ix) = sh.Name
ix = ix + 1
End If
Next
ReDim Preserve shArray(ix - 1)
ActiveWorkbook.Sheets(shArray).Select
ActiveWorkbook.Windows(1).SelectedSheets.Copy
ActiveWorkbook.SaveAs WBspeichern
Application.DisplayAlerts = True
ActiveWorkbook.Close savechanges:=False
End Sub
legt zwar eine Mappe an nennt sie aber nur Mappe XXX und läßt sie offen.
mfg Karl