Hallo zusammen,
ich habe folgendes Makro geschrieben:
In der tabelle:
Private Sub CommandButton74_Click()
Dim x As String
x = "One"
Call Printer(x)
End Sub
Als Modul:
Sub Printer (x As String)
Dim wks As Worksheet
Application.ScreenUpdating = False
Call unProtect
For Each wks In ThisWorkbook.Worksheets
If wks.Range("A3") = x Or wks.Range("A2") = x Or wks.Range("A1") = x Then
wks.Visible = True
wks.Select
GoTo Continue
End If
Next wks 'Diese Part damit einer der bestroffenen Blätter selektiert wird
Continue:
For Each wks In ThisWorkbook.Worksheets
If wks.Range("A3") = x Or wks.Range("A2") = x Or wks.Range("A1") = x Then
wks.Visible = True
wks.Outline.ShowLevels RowLevels:=1
wks.Outline.ShowLevels ColumnLevels:=1
wks.Select (False)
End If
Next wks
ActiveWindow.SelectedSheets.PrintPreview
For Each wks In ThisWorkbook.Worksheets
If wks.Index 1 Then
wks.Visible = False
End If
Next wks
Tabelle1.Select
Call Protection
Application.ScreenUpdating = True
End Sub
Trotz wks.Select (False) ist zum Schluss immer nur der erste und der letzte Blatt markiert. Alle andere Blätter sind zwar zu sehen (visible = true funktioniert) aber nicht markiert. Wäre eine Lösung, diese Blätter in einen Array zu tun, den man dann markiert? Wie würde das gehen bzw. alternative Lösung?
Danke für die Unterstützung und Gruss
Salim