Anzeige
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
Anzeige
Inhaltsverzeichnis

Positionierung der Inputbox

Forumthread: Positionierung der Inputbox

Positionierung der Inputbox
07.04.2026 21:05:42
Ringberger
Hallo an alle fleißigen Helfer,

ich habe hier das Makro, bei dem die Inputbox geöffnet wird um einen Betrag einzugeben. Funktioniert auch tadellos. Standartmäßig wird diese in der Mitte des Bildschirms angezeigt. Ich brauche aber die Position der Inputbox eine viertel Bildschirmbreite weiter links. Ich habe es auch schon mit einem Tipp aus eurem Forum probiert, geht aber auch nicht.
Sub Splittbuchungsbetrag_eingeben()


Dim eingabe As Variant
Dim zahl As Double
Dim ws As Worksheet
Dim Gammac As Variant

' InputBox anzeigen
eingabe = InputBox("Bitte Betrag eingeben:", "Eingabe Betrag von Kontoauszug oder Kassenbon:")

' Abbrechen gedrückt?
If eingabe = "" Then
MsgBox "Eingabe abgebrochen."
Exit Sub
End If

' Prüfen, ob Eingabe eine Zahl ist
If IsNumeric(eingabe) Then
zahl = CDbl(eingabe)
Else
MsgBox "Die Eingabe ist keine gültige Zahl."
Exit Sub
End If

' Zahl in definierte Zelle schreiben
Tabelle92.Range("AC54").Value = zahl

MsgBox "Betrag erfolgreich eingetragen: " & zahl

End Sub


Ich hoffe auf eure Hilfe. Danke.

Andreas
Anzeige

6
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
Nicht möglich, nutze eine UserForm
07.04.2026 22:42:28
Henner
Hallo Andreas

Eine InputBox kannst Du nicht positionieren. Erstelle eine UserForm, damit kannst Du das machen:



Me.StartUpPosition = 0
Me.Left = Application.Left + (Application.Width / 4)
Me.Top = Application.Top + (Application.Height / 2) - (Me.Height / 2)


Gruss Henner
Anzeige
Doch möglich!
08.04.2026 00:15:15
xlKing
Moin,

Wer behauptet hier, das sei nicht möglich? Die Inputbox bringt die Eigenschaften xpos und ypos mit. Deren Einheit sind Twips. Ein Twip ist ein Zwanzigstel Punkt.

Probier mal Folgendes:
eingabe = InputBox("Bitte Betrag eingeben:", "Eingabe Betrag von Kontoauszug oder Kassenbon:", xpos:=Application.Width / 4 * 20, ypos:=Application.Height / 3 * 20)


Das eigentliche Problem dürfte aber die Bildschirmbreite sein. Jeder Bildschirm hat eine andere Breite. Insofern kann es auch zu weit links oder nicht weit genug links erscheinen. Für dich selbst sollte obige Formel aber ausreichen.

Gruß Mr. K.
Anzeige
Inputbox platzieren
08.04.2026 13:52:07
Ringberger
Es ist genau der Tipp, den ich gebraucht habe. Ich konnte die Inputbox dort platzieren, wo ich sie gebraucht habe. Nun ist unser kleines Kassenbuch perfekt. Ich bin überglücklich mit diesem relativ kleinen Zusatz das Ziel erreicht zu haben. Danke vielmals.
Positionierung der Inputbox
08.04.2026 00:56:38
volti
Hallo Andreas,

mit ein paar API-Funktionen lässt sich an einer Inputbox fast alles manipulieren. Auch die Positionierung oder die Größe der Inputbox.

Falls xlKings Vorschlag nicht zum Ziel führen sollte, kannst Du gerne auch nachfolgenden Code ausprobieren, an dem natürlich auch noch gefeilt werden kann.
Dieser ist sicher deutlich umfangreicher, kann dafür aber die Inputbox pixelgenau in Abhängigkeit vom Bildschirm positionieren,
Private Declare PtrSafe Function SetTimer Lib "user32" ( _

ByVal hwnd As LongPtr, ByVal nIDEvent As LongPtr, _
ByVal uElapse As Long, ByVal lpTimerFunc As LongPtr) As LongPtr
Private Declare PtrSafe Function KillTimer Lib "user32" ( _
ByVal hwnd As LongPtr, ByVal nIDEvent As LongPtr) As Long
Private Declare PtrSafe Function GetActiveWindow Lib "user32" () As LongPtr
Private Declare PtrSafe Function SetWindowPos Lib "user32" ( _
ByVal hwnd As LongPtr, ByVal hWndInsertAfter As LongPtr, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private Declare PtrSafe Function GetWindowRect Lib "user32" ( _
ByVal hwnd As LongPtr, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare PtrSafe Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private R As RECT
Private Const SWP_NOSIZE As Long = &H1
Private mhTimer As LongPtr

Private Sub InputBox_CallbackProc()
KillTimer 0&, mhTimer ' Timer löschen
GetWindowRect GetActiveWindow, R ' Alte Position holen
R.Left = GetSystemMetrics(0) \ 4 ' x-Position auf ein Viertel Bildschirm setzen
SetWindowPos GetActiveWindow, 0, R.Left, R.Top, 0, 0, SWP_NOSIZE ' Dlg-Position anpassen
End Sub



Public Sub Test()
Dim sResult As String
mhTimer = SetTimer(0&, 0&, 10, AddressOf InputBox_CallbackProc) ' Timer setzen
sResult = InputBox("Mein Text", "Mein Titel", "Meine Vorgabe") ' (Excel)-Inputbox starten
End Sub


Gruß
Karl-Heinz
Anzeige
position
08.04.2026 14:12:37
snb
oder:


Sub M_snb_scherm()

With CreateObject("word.application").System
sn = Array(.HorizontalResolution, .VerticalResolution)
.Parent.Quit
End With

c00 = InputBox("Betrag", "Kassenbon:", 3* (sn(0)/ 8))
End Sub





Anzeige
Update
08.04.2026 01:56:23
volti
Hier noch mal für Dein Beispiel....
Private Declare PtrSafe Function SetTimer Lib "user32" ( _

ByVal hwnd As LongPtr, ByVal nIDEvent As LongPtr, _
ByVal uElapse As Long, ByVal lpTimerFunc As LongPtr) As LongPtr
Private Declare PtrSafe Function KillTimer Lib "user32" ( _
ByVal hwnd As LongPtr, ByVal nIDEvent As LongPtr) As Long
Private Declare PtrSafe Function GetActiveWindow Lib "user32" () As LongPtr
Private Declare PtrSafe Function SetWindowPos Lib "user32" ( _
ByVal hwnd As LongPtr, ByVal hWndInsertAfter As LongPtr, _
ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
Private Declare PtrSafe Function GetWindowRect Lib "user32" ( _
ByVal hwnd As LongPtr, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare PtrSafe Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Private R As RECT
Private Const SWP_NOSIZE As Long = &H1
Private mhTimer As LongPtr

Private Sub InputBox_CallbackProc()
KillTimer 0&, mhTimer ' Timer löschen
GetWindowRect GetActiveWindow, R ' Alte Position holen
R.Left = GetSystemMetrics(0) \ 4 ' x-Position auf ein Viertel Bildschirm setzen
SetWindowPos GetActiveWindow, 0, R.Left, R.Top, 0, 0, SWP_NOSIZE ' Dlg-Position anpassen
End Sub


Sub Splittbuchungsbetrag_eingeben()

Dim eingabe As Variant
Dim zahl As Double
Dim ws As Worksheet
Dim Gammac As Variant

' InputBox anzeigen
mhTimer = SetTimer(0&, 0&, 10, AddressOf InputBox_CallbackProc) ' Timer setzen
eingabe = InputBox("Bitte Betrag eingeben:", "Eingabe Betrag von Kontoauszug oder Kassenbon:")

' Abbrechen gedrückt?
If eingabe = "" Then
MsgBox "Eingabe abgebrochen."
Exit Sub
End If

' Prüfen, ob Eingabe eine Zahl ist
If IsNumeric(eingabe) Then
zahl = CDbl(eingabe)
Else
MsgBox "Die Eingabe ist keine gültige Zahl."
Exit Sub
End If

' Zahl in definierte Zelle schreiben
Tabelle92.Range("AC54").Value = zahl

MsgBox "Betrag erfolgreich eingetragen: " & zahl

End Sub
Anzeige
Anzeige
Anzeige
Live-Forum - Die aktuellen Beiträge
Datum
Titel
14.05.2026 13:31:09
14.05.2026 09:50:42
13.05.2026 19:14:18