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.
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
6,479
Office Version
  1. 2019
Platform
  1. Windows
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
 

Keamogetswe

New Member
Joined
May 12, 2020
Messages
10
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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.
 

dmt32

Well-known Member
Joined
Jul 3, 2012
Messages
6,479
Office Version
  1. 2019
Platform
  1. Windows
Makes sense but its a different question to the one answered. Really should start new thread - likely to more responses

Dave
 

Watch MrExcel Video

Forum statistics

Threads
1,127,347
Messages
5,624,136
Members
416,012
Latest member
rockermom59

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
Top