AW: Formeln und Code sollen nicht mit kopiert werd
13.11.2007 20:49:09
Erich
Hallo Peter,
probier mal
Option Explicit
Public Sub Auslagern2()
Dim wbkA As Workbook, strBL, ii As Integer, lngL As Long, rng As Range, jj As Integer
Application.ScreenUpdating = False
Worksheets("Turnierbericht").Visible = True
Set wbkA = ActiveWorkbook
strBL = Array("Obedience", "WKKlasseBeginner", "WKKlasse1", "WKKlasse2", "WKKlasse3", _
"IdentListe", "TurnierBericht")
Workbooks.Add xlWBATWorksheet
For ii = 0 To UBound(strBL)
If ii > 0 Then Worksheets.Add after:=Sheets(Worksheets.Count)
ActiveSheet.Name = strBL(ii)
With wbkA.Sheets(strBL(ii))
Set rng = .Cells.Find("*", .Cells(1, 1), xlValues, , xlByRows, xlPrevious)
If rng Is Nothing Then lngL = 1 Else lngL = rng.Row
ReDim hh(1 To lngL)
For jj = 1 To lngL
hh(jj) = .Rows(jj).RowHeight
Next jj
.Columns.Copy
End With
With Range("A1")
.PasteSpecial Paste:=xlPasteFormats
.PasteSpecial Paste:=xlPasteValues
End With
Application.CutCopyMode = False
For jj = 1 To lngL
Rows(jj).RowHeight = hh(jj)
Next jj
Cells(1, 1).Select
Next ii
Application.ScreenUpdating = False
ActiveWorkbook.SaveAs "C:\Obedience\PSV1912Nbg\Daten\" & _
UserForm2.TextBox1.Value & "-" & Date
ActiveWorkbook.Close
ThisWorkbook.Saved = True
End Sub
Das Ganze ginge etwas schneller, wenn man statt der Spalten die (vielen) Zeilen kopiert
und die Spaltenbreiten nachher überträgt. Momentan ist es gerade umgekehrt (hatte ich schon).
Rückmeldung wäre nett! - Grüße von Erich aus Kamp-Lintfort