wie kann ich folgendem Makro sagen, dass es das gefundene Blatt auswählen soll?
Sub blatt_vorhanden_prüfen()
Dim Ws As Worksheet, wb As Workbook, strBook As Variant
Dim bolExist As Boolean, n As Integer, strWb As String
Dim strSheet As String
'On Error Resume Next
If UserForm2.TextBox1.Value = "A." Or UserForm2.TextBox1.Value = "" Then Exit Sub
strSheet = UserForm2.TextBox1.Value
strBook = Array(ThisWorkbook.Path & "\Prüfblätter1.xls", ThisWorkbook.Path & "\Prüfblätter2.xls", ThisWorkbook.Path & "\Prüfblätter3.xls")
For n = 1 To UBound(strBook)
Workbooks.Open strBook(n)
For Each Ws In ActiveWorkbook.Worksheets
If Ws.Name = strSheet Then
bolExist = True
strWb = ActiveWorkbook.Name
GoTo Ende
End If
Next Ws
'Workbooks(strBook(n)).Close
Next n
Ende:
If bolExist Then
MsgBox "Blatt " & strSheet & " gefunden in " & strWb, , "Treffer..."
'ActiveSheet.Select
'Call shutdown
Unload UserForm2
UserForm1.Show
'Workbooks(strBook(n)).Close
Else
MsgBox "Blatt " & strSheet & " nicht gefunden...", , "Fehlanzeige"
If MsgBox("Blattname existiert nicht. Neues Prüfblattlatt anlegen?", vbYesNo) = vbNo Then
UserForm2.Show
Exit Sub
Else
'Unload UserForm2
' Call Makro_neues_Blatt_anlegen
' UserForm4.Show
' ActiveSheet.Visible = True
' ActiveSheet.Name = Range("K2").Value
' UserForm1.Show
End If
End If
End Sub
Brauche das, um mit dem Sheet arbeiten zu können.
Gruß Andi