599 Aufrufe
Gefragt in Tabellenkalkulation von
Hallo zusammen,

ich habe in Excel eine VBA Programmierung zur Abfrage eine Passwortes, die wie folgt aussieht:

Sub Schaltfläche2_Klicken()
Dim vrAnt As Variant
vrAnt = Application.InputBox("Passwort Modifikation", "Eingabe", Type:=2)
If StrPtr(vrAnt) = 0 Then
Exit Sub
Else
If vrAnt = vbNullString Then
MsgBox "Bitte geben Sie ein Passwort ein."
Else
If vrAnt = "Modifikation" Then Worksheets("Modifikation_Tischlerei").Visible = True
End If
End If
End Sub


Bei Eingabe des falschen Passwortes, soll eine Meldung erscheinen (Msgbox) "Eingabe falsches Passwort".

Kann mir bitte jemand weiterhelfen, wie das funktioniert?

1 Antwort

0 Punkte
Beantwortet von m-o Profi (22.9k Punkte)
Hallo,

ich nehme mal an, dass "Modifikation" dein Passwort ist. Versuch mal den folgenden Code:

Sub Schaltfläche2_Klicken()
Dim vrAnt As Variant

vrAnt = Application.InputBox("Passwort Modifikation", "Eingabe", Type:=2)

'keine Eingabe oder Abbruch
If vrAnt = "" Or vrAnt = "Falsch" Then
MsgBox "Bitte geben Sie ein Passwort ein!", 16, "Abbruch!"
Exit Sub
End If
'Falsche Eingabe; Passwort anpassen!!!
If vrAnt <> "Modifikation" Then
MsgBox "Falsches Passwort!", 16, "Abbruch!"
Exit Sub
End If

'Blatt einblenden
If Worksheets("Modifikation_Tischlerei").Visible = False Then Worksheets("Modifikation_Tischlerei").Visible = True

End Sub


Gruß
M.O.
...