04.04.2016, 20:44
Code:
Sub M_snb()
Do
c00 = InputBox("worksheet ")
Loop Until Evaluate("isref(" & c00 & "!A1)")
sheets(c00).cells(1)="Prima"
End Sub
Sub M_snb()
Do
c00 = InputBox("worksheet ")
Loop Until Evaluate("isref(" & c00 & "!A1)")
sheets(c00).cells(1)="Prima"
End Sub
Option Explicit Sub RPP() Dim Eingabe As String, wks As Worksheet Check: Eingabe = Application.InputBox("Tabellenblatt") On Error Resume Next Set wks = ThisWorkbook.Worksheets(Eingabe) If Err.Number > 0 Then GoTo Check Else MsgBox "Glückwunsch!" On Error GoTo 0 End Sub
Function SheetExists(sBook, sName) As Boolean Dim x As Worksheet On Error Resume Next Set x = Workbooks(sBook).Sheets(sName) If Err = 0 Then SheetExists = True End Function
Sub RPP() Dim Eingabe As String Check: Eingabe = Application.InputBox("Tabellenblatt") If Not SheetExists(ThisWorkbook.Name, Eingabe) Then GoTo Check MsgBox "Glückwunsch!" End Sub
Die On Error - Methode sollte nur dafür eingesetzt werden, wenn Du nicht "klug" programmiert hast.
If c00 = "" Then
Msgbox "Nix eingegeben!"
tue irgendwas (z.B. String c00 mit "xxx" ersetzen" in der Hoffnung, dass es so ein Blatt nicht gibt)
End if
Sub Test()
c00 = InputBox("worksheet ")
If IsError(Application.Evaluate("=" & c00 & "!A1")) Then MsgBox "Nix Blattda" Else MsgBox "Blattda"
End Sub
Sub Test2()
If IsError(Application.Evaluate("=" & InputBox("worksheet ") & "!A1")) Then MsgBox "Nix Blattda" Else MsgBox "Blattda"
End Sub