mit folgendem Code formatiere ich alle Arbeitsbätter in einer Datei. Ich will d. Code so erweitern, dass die in allen Arbeitsblättern enthaltenen Tabellen nach Spalte A aufsteigend sortiert werden. Aber es wird nur die Tabelle im ersten Blatt sortiert. Was mache ich falsch?
Gruß Thomas
Sub Formate()
Dim wks As Worksheet
Dim sTxt As String
Dim kTxt As String
sTxt = "ABGEARBEITET: "
kTxt = "Liste"
For Each wks In ActiveWorkbook.Sheets
With wks.PageSetup
.PrintGridlines = True
'.LeftFooter = "&10" & sTxt
'.LeftHeader = "&""Arial,Fett""&14" & kTxt
.LeftFooter = "&""Arial,Fett""&10" & sTxt
.LeftMargin = Application.CentimetersToPoints(2.1)
.RightMargin = Application.CentimetersToPoints(1.1)
.TopMargin = Application.CentimetersToPoints(1.2)
.BottomMargin = Application.CentimetersToPoints(1.2)
.HeaderMargin = Application.CentimetersToPoints(0.5)
.FooterMargin = Application.CentimetersToPoints(0.5)
End With
With wks
Range("A2", "B" & ActiveCell.SpecialCells(xlLastCell).Row).Sort _
Key1:=Range("A2"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
End With
Next wks
ActiveWorkbook.PrintPreview
End Sub