Input box

Keamogetswe

New Member
Joined
May 12, 2020
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Hi, how could I detect whether the user has pressed cancel button on the application. Inputbox

Here is the line of code

Dim pin as integer

pin = application. Inputbox("ENTER PIN",,,,,,, 1)

'The input box only takes in numbers,
Thank you for your help.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi
Try following update to your code & see if helps

VBA Code:
Dim pin As Variant

pin = Application.InputBox("ENTER PIN", , , , , , , 1)
'cancel pressed
If VarType(pin) = vbBoolean Then Exit Sub

Dave
 
Upvote 0
Hi Dave one more thing to ask, I have inserted a combo box(form control) in one of my sheets and assigned a range of strings e.g Months. My problem is how do I reset the box to default that is "there is no selection prior next selection"
e.g current selection May when I want to use it again it still shows May and I want it not to show anything so I can select June.

Hopefully that makes sense, thanks again.
 
Upvote 0
Makes sense but its a different question to the one answered. Really should start new thread - likely to more responses

Dave
 
Upvote 0

Forum statistics

Threads
1,213,482
Messages
6,113,916
Members
448,533
Latest member
thietbibeboiwasaco

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