Forum Discussion
Excel
Aug 03, 2022Iron Contributor
Query related to VBA code
Hello Everyone, I am trying to work with input variable and using msgbox- if the information is correct-> then there should be no "Please re-enter your PURCHASED ORDER number" Please help.. ...
- Aug 03, 2022
Give a try on below sub
Public Sub Information() ReEnter: ' Create inputbox, and (2) asssign value returned by inputbox function to variable myInputBoxVariable = InputBox(prompt:="Please enter your PO number", Title:="PO Number") ' Display message box with value held by varaible If IsNumeric(myInputBoxVariable) Then MsgBox " Your PO number is: " & myInputBoxVariable Else GoTo Incorrect End If ' If error, check with the PO value again On Error GoTo Incorrect Exit Sub Incorrect: MsgBox "Please re-enter your PO number" GoTo ReEnter End Sub
Harun24HR
Aug 03, 2022Bronze Contributor
Give a try on below sub
Public Sub Information()
ReEnter:
' Create inputbox, and (2) asssign value returned by inputbox function to variable
myInputBoxVariable = InputBox(prompt:="Please enter your PO number", Title:="PO Number")
' Display message box with value held by varaible
If IsNumeric(myInputBoxVariable) Then
MsgBox " Your PO number is: " & myInputBoxVariable
Else
GoTo Incorrect
End If
' If error, check with the PO value again
On Error GoTo Incorrect
Exit Sub
Incorrect: MsgBox "Please re-enter your PO number"
GoTo ReEnter
End Sub
Excel
Aug 03, 2022Iron Contributor
Thank you so much sir