wie kann ich mit einem Makro ein (oder mehrere) anderes Makro ausführen?
Zugleich sollte dieses Makro nicht nur im aktuellen Tabellenblatt, sondern in allen Tabellenblättern der Datei ausgeführt werden.
sub test0()
call test1
call test2
end sub
Sub Test1()
end sub
Sub Test1()
end sub
Hoff das hilft weiter.
Option Explicit
Sub Hauptmakro()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
Untermakro ws
' oder
Call Untermakro(ws)
Next ws
End Sub
Sub Untermakro(wks As Worksheet)
With wks
.Cells(1, 1).Value = Now
.Cells(1, 2).Value = .Name
End With
End Sub
Ob man "Call" hinschreibt oder es weglässt, ist Geschmackssache.
Option Explicit
Sub EinMakro()
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
With ws
.Cells(1, 1).Value = Now
.Cells(1, 2).Value = .Name
End With
Next ws
End Sub
Rückmeldung wäre nett! - Grüße aus Kamp-Lintfort von Erich
Sub EinMakro()
Dim sh_Alt As Object, wks As Worksheet
Application.ScreenUpdating = False
Application.EnableEvents = False
On Error GoTo XErr
Set sh_Alt = ActiveSheet
For Each wks In ActiveWorkbook.Worksheets
With wks
.Unprotect
.Range("I:I,K:K,N:O").EntireColumn.Hidden = True
With .Range("A1").Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 12611584
.TintAndShade = 0
.PatternTintAndShade = 0
End With
.Activate
ActiveWindow.Zoom = 75
.Protect DrawingObjects:=True, Contents:=True, _
Scenarios:=True, AllowFiltering:=True
End With
Next wks
sh_Alt.Activate
XErr:
Application.EnableEvents = True
Application.ScreenUpdating = True
Resume XEnd
XEnd:
End Sub
Ich bin jetzt mal für zwei, drei Wochen weg...