vbCancel = True

theta

Well-known Member
Joined
Jun 9, 2009
Messages
960
Hi,

I have the following section of VBA code which works :

CONTRACT = Application.InputBox("Please enter Contract no", "LIFT DETAILS")
If CONTRACT = False Then
Exit Sub
End If


I would rather use the vbCancel object but it gives me 13 error :

CONTRACT = Application.InputBox("Please enter Contract no", "LIFT DETAILS")
If vbCancel = True Then
Exit Sub
End If


Help please?
 

Some videos you may like

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.

Andrew Poulsom

MrExcel MVP
Joined
Jul 21, 2002
Messages
73,092
Sorry, that's not possible. vbCancel (value 2) is a member of vbMsgBoxResult and there is no such Enum for an InputBox.
 

theta

Well-known Member
Joined
Jun 9, 2009
Messages
960
I was told if I asked excel nicely it might work? No?
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
35,523
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
No. As a great man once said "this is programming, not magic, unfortunately". ;)
 

Watch MrExcel Video

Forum statistics

Threads
1,109,505
Messages
5,529,264
Members
409,859
Latest member
emperorgenghiskhan
Top