fehlermeldung: Objekt erforderlich
14.02.2005 16:34:53
andi
habe folgendes Makro:
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 TextBox1.Value = "A." Or TextBox1.Value = "" Then Exit Sub
strSheet = 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..."
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
Erstaunlicherweise hat dieses Makro schon funktioniert. Jetzt kommt der Fehler: Objekt erfoderlich.
Der Debugger meldet diese Zeile:
If TextBox1.Value = "A." Or TextBox1.Value = "" Then Exit Sub
strSheet = TextBox1.Value
Habe auch schon probiert das "if" wegzulassen, auch schon mit "on error resume next".
Leider hat alles nichts gebracht. Vielleicht weiß ja jemand Rat und kann mir helfen?!
Ich jedenfalls komme nicht mehr weiter...
Gruß Andi