HERBERS Excel-Forum - die Beispiele

Thema: Beispiele zum Einsatz der InputBox

Home

Gruppe

Dialog

Problem

10 Beispiele zum Einsatz der eingebauten InputBox

Lösung
Geben Sie den Code in ein Standardmodul ein und weisen Sie ihn Schaltflächen zu.
StandardModule: Modul1

Sub CallVBA()
   Dim sTxt As String
   sTxt = InputBox("Bitte Eingabe tätigen:")
   If sTxt = "" Then Exit Sub
   MsgBox sTxt
End Sub

Sub CallXL()
   Dim vTxt As Variant
   vTxt = Application.InputBox("Bitte Eingabe tätigen:")
   If vTxt = False Then Exit Sub
   MsgBox vTxt
End Sub

Sub SetPrompt()
   Dim sTxt As String, sPrompt As String
   sPrompt = "Nutzen Sie bitte folgende Syntax:" & vbLf & _
   "   'dd.mm.yyyy' oder" & vbLf & _
   "   'dd/mm/yyyy' oder" & vbLf & _
   "   'dd-mm-yyyy':"
   sTxt = InputBox(prompt:=sPrompt)
   On Error GoTo ERRORHANDLER
   MsgBox CDate(sTxt)
   Exit Sub
ERRORHANDLER:
   MsgBox "Kein gültiges Datumsformat!"
End Sub

Sub SetTitle()
   Dim sTxt As String, sTitle As String
   sTitle = Application.UserName & " says:"
   sTxt = InputBox(prompt:="Eingabe:", Title:=sTitle)
   If sTxt = "" Then Exit Sub
   MsgBox sTxt
End Sub

Sub SetDefault()
   Dim sTxt As String, sPrompt As String, sDefault As String
   sPrompt = "Eingangsdatum eingeben:"
   sDefault = Format(Date - 3, "dd.mm.yyyy")
   sTxt = InputBox(prompt:=sPrompt, Default:=sDefault)
   On Error GoTo ERRORHANDLER
   MsgBox CDate(sTxt)
   Exit Sub
ERRORHANDLER:
   MsgBox "Kein gültiges Datumsformat!"
End Sub

Sub SelDefault()
   Dim sTxt As String, sPrompt As String, sDefault As String
   sPrompt = "Eingangsdatum eingeben:"
   sDefault = Format(Date - 3, "dd.mm.yyyy")
   SendKeys "{home}{right 3}+{right 2}"
   sTxt = InputBox(prompt:=sPrompt, Default:=sDefault)
   On Error GoTo ERRORHANDLER
   MsgBox CDate(sTxt)
   Exit Sub
ERRORHANDLER:
   MsgBox "Kein gültiges Datumsformat!"
End Sub
Application.InputBox

Sub InputBoxPositionA()
   Dim sTxt As String, sPrompt As String
   sPrompt = "Eingabe:"
   sTxt = InputBox(prompt:="Eingabe:", xpos:=1000, ypos:=1000)
End Sub

Sub InputBoxPositionB()
   Dim rng As Range
   Dim iLeft As Integer, iTop As Integer
   Dim sTxt As String, sPrompt As String
   Set rng = Range("B3")
   iLeft = rng.Left + 23
   iTop = rng.Top + 16
   sPrompt = "Eingabe:"
   sTxt = Application.InputBox( _
      prompt:="Eingabe:", Left:=iLeft, Top:=iTop)
End Sub

Sub CallHelpA()
   Dim sTxt As String, sPrompt As String, sFile As String
   sFile = "..\..\2001\Beispiele\Kontext.chm"
   If Dir(sFile) = "" Then
      Beep
      MsgBox "Hilfedatei existiert nicht!"
      Exit Sub
   End If
   sPrompt = "Eingabe:"
   sTxt = InputBox( _
      prompt:="Eingabe:", _
      HelpFile:=sFile, _
      Context:="1001")
End Sub

Sub CallHelpB()
   Dim sTxt As String, sPrompt As String, sFile As String
   sFile = "..\..\2001\Beispiele\Kontext.chm"
   If Dir(sFile) = "" Then
      Beep
      MsgBox "Hilfedatei existiert nicht!"
      Exit Sub
   End If
   sPrompt = "Eingabe:"
   sTxt = Application.InputBox( _
      prompt:="Eingabe:", _
      HelpFile:=sFile, _
      HelpContextID:="1001")
End Sub

Beiträge aus dem Excel-Forum zu den Themen Dialog und InputBox

Cursor Inputbox xlDialogInsertHyperlink.show
Wiederholung - Inputbox Inputbox erstellen
InputBox Arbeitmappen über Dialogfeld zusammen fassen
5.0 Dialog Speichern unter Dialog in Word aufrufen inkl. Pfad
Frage zu InputBox Druckerdialog
Dateityp im "Speichern unter"-Dialog vorgeben Makro stoppen, wenn Excel-Dialog?
xlDialogOpen anpassen Alternative Eingaben über InputBox
Klick in definierten Rangebereich startet Dialog Bereich per INPUTBOX markieren und auswerten
InputBox Fehlermeldung bei Inputbox-Abbruch
Inputbox: Schließkreuz auswerten + Sub beenden xlDialogOpen bei Excel 2007 funzt nicht
FileDialog inkl. Anklicken von Desktop, Eigene D. SheetIndex aus Range- Inputbox auslesen
InputBox mit Gültigkeit Inputbox mit Paßwortfeld
InputBox - Eingabeformat abfangen Grösse Dialogfenster der InputBox
Inputbox f. Range läßt sich nicht abbrechen InputBox Eingabe Erweiterung
Dialogfeld unterdrücken Zelle über Inputbox füllen
Inputbox Abbrechen mit Exit Sub belegen Dialog "permanently delete sheets" unterbinden
Format-Dialog funktioniert nicht mehr Dialog "Verknüpfung aktualisieren"
Negative Uhrzeit über Inputbox eingeben InputBox muss ausgefüllt werden
Inputboxabfrage für Dezimalstellen/ Abbrechen Ordnerdialog und Dateidialog
Ordnerdialog und dateidialog Ordnerdialog und Dateidialog
Filedialog PrintTitleRows flexibel über Inputbox
Inputbox: Zahlenprüfung/ Abbruch zulassen Herber/Beispiele/Dialoge/Checkbox/137601
Rows("6:6") über Inputbox Bilder bei Click im Dialogfeld
Suchdialog über VBA aufrufen mit Wert aus Combobox Dialog öffnen
Diagramm als Grafik mit Speicherdialog exportieren Dialogfenster zum kopieren