Restrict user response for InputBox

maxwell13

New Member
Joined
Jan 25, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi All

I would like to restrict user response in a Input Box to a specific format of the below examples.

12.34.5678

11.27.9832

Basically 2 digits a period 2 digits a period and 4 digits.

Any help is greatly appreciated.

Thanks
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Try:
VBA Code:
Sub tryInputbox()
Dim sVar As Variant

Do
    sVar = Application.InputBox("Insert... :", Title, Type:=2)
    
    If sVar = False Then Exit Sub  'if user cancel
        If Not sVar Like "##.##.####" Then
            MsgBox "Incorrect ... "
        Else
            'do something
            Exit Do
        End If

Loop While Not sVar Like "##.##.####"
            

End Sub
 
Upvote 0
Solution
Thank you Akuini for your prompt reply. That looks like it will do exactly as i needed.

I will test it out and let you know how i go


 
Upvote 0

Forum statistics

Threads
1,215,223
Messages
6,123,715
Members
449,118
Latest member
MichealRed

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top