Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Input Box - Hit cancel

It there not really a direct way to tell if the Cancel button was clicked of
an InputBox. I was told in an earlier posting to do something like this:

EnterState = InputBox("Enter State: ")
If EnterState < "" Then
ActiveCell.Value = EnterState
Else
ActiveCell.Value = Null
Endif

'----But----
What I want is if the cancel is pressed don't do anything. What is
happening is if for example the current cell value is "Florida" ; and the
InputBox opens and the person puts "North Carolina" in the InputBox field and
then changes their mind and clicks Cancel, then the cell value is
erased....when it should still say "Florida"

How do you catch the Cancel key press and tell it don't do anything.

Thank you for your help.

Steven
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 709
Default Input Box - Hit cancel

Steven, try this,

EnterState = InputBox("Enter State: ")
If EnterState < "" Then ActiveCell.Value = EnterState


--
Paul B
Always backup your data before trying something new
Please post any response to the newsgroups so others can benefit from it
Feedback on answers is always appreciated!
Using Excel 2002 & 2003

"Steven" wrote in message
...
It there not really a direct way to tell if the Cancel button was clicked

of
an InputBox. I was told in an earlier posting to do something like this:

EnterState = InputBox("Enter State: ")
If EnterState < "" Then
ActiveCell.Value = EnterState
Else
ActiveCell.Value = Null
Endif

'----But----
What I want is if the cancel is pressed don't do anything. What is
happening is if for example the current cell value is "Florida" ; and the
InputBox opens and the person puts "North Carolina" in the InputBox field

and
then changes their mind and clicks Cancel, then the cell value is
erased....when it should still say "Florida"

How do you catch the Cancel key press and tell it don't do anything.

Thank you for your help.

Steven



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 380
Default Input Box - Hit cancel

Dim EnterState As Variant
EnterState = InputBox("Enter State: ")
If EnterState < "" Then
ActiveCell.Value = EnterState
Else
ActiveCell.Value = Null
End If

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Steven" wrote in message
...
It there not really a direct way to tell if the Cancel button was clicked

of
an InputBox. I was told in an earlier posting to do something like this:

EnterState = InputBox("Enter State: ")
If EnterState < "" Then
ActiveCell.Value = EnterState
Else
ActiveCell.Value = Null
Endif

'----But----
What I want is if the cancel is pressed don't do anything. What is
happening is if for example the current cell value is "Florida" ; and the
InputBox opens and the person puts "North Carolina" in the InputBox field

and
then changes their mind and clicks Cancel, then the cell value is
erased....when it should still say "Florida"

How do you catch the Cancel key press and tell it don't do anything.

Thank you for your help.

Steven



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Input Box - Hit cancel

As an observation, both Paul's and Bob's solutions cause the Input Box to
display twice. Also I had to change the "" to Empty to get Bob's to work.
They both leave The active cell intact with the modification I mentioned.

Qustion for Steven: Is there a way to accomplish your goal without
overwriting the active cell. Stated differently, could you control the
conditions so that the user would not have to make the decision to cancel and
thereby eliminate the problem?

"Bob Phillips" wrote:

Dim EnterState As Variant
EnterState = InputBox("Enter State: ")
If EnterState < "" Then
ActiveCell.Value = EnterState
Else
ActiveCell.Value = Null
End If

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Steven" wrote in message
...
It there not really a direct way to tell if the Cancel button was clicked

of
an InputBox. I was told in an earlier posting to do something like this:

EnterState = InputBox("Enter State: ")
If EnterState < "" Then
ActiveCell.Value = EnterState
Else
ActiveCell.Value = Null
Endif

'----But----
What I want is if the cancel is pressed don't do anything. What is
happening is if for example the current cell value is "Florida" ; and the
InputBox opens and the person puts "North Carolina" in the InputBox field

and
then changes their mind and clicks Cancel, then the cell value is
erased....when it should still say "Florida"

How do you catch the Cancel key press and tell it don't do anything.

Thank you for your help.

Steven




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Input Box - Hit cancel

Neither one causes the inputbox to display twice if run as written.

But Bob's clears the cell on cancel if run as written.

Believe he meant

Sub bBB()
Dim EnterState As Variant
EnterState = InputBox("Enter State: ")
If EnterState < "" Then
ActiveCell.Value = EnterState
End If
End Sub


--
Regards,
Tom Ogilvy


"JLGWhiz" wrote in message
...
As an observation, both Paul's and Bob's solutions cause the Input Box to
display twice. Also I had to change the "" to Empty to get Bob's to work.
They both leave The active cell intact with the modification I mentioned.

Qustion for Steven: Is there a way to accomplish your goal without
overwriting the active cell. Stated differently, could you control the
conditions so that the user would not have to make the decision to cancel
and
thereby eliminate the problem?

"Bob Phillips" wrote:

Dim EnterState As Variant
EnterState = InputBox("Enter State: ")
If EnterState < "" Then
ActiveCell.Value = EnterState
Else
ActiveCell.Value = Null
End If

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Steven" wrote in message
...
It there not really a direct way to tell if the Cancel button was
clicked

of
an InputBox. I was told in an earlier posting to do something like
this:

EnterState = InputBox("Enter State: ")
If EnterState < "" Then
ActiveCell.Value = EnterState
Else
ActiveCell.Value = Null
Endif

'----But----
What I want is if the cancel is pressed don't do anything. What is
happening is if for example the current cell value is "Florida" ; and
the
InputBox opens and the person puts "North Carolina" in the InputBox
field

and
then changes their mind and clicks Cancel, then the cell value is
erased....when it should still say "Florida"

How do you catch the Cancel key press and tell it don't do anything.

Thank you for your help.

Steven








  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Input Box - Hit cancel


Thanks Tom. That was the winner.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Input Box Cancel Jase Excel Discussion (Misc queries) 2 September 15th 08 11:42 PM
Input Box - CANCEL Danny Excel Worksheet Functions 6 December 1st 06 02:15 AM
Input box to cancel sub when Cancel is clicked. PCLIVE Excel Programming 5 September 5th 06 03:19 PM
Input box cancel Little Penny Excel Programming 1 August 25th 06 11:50 PM
cancel input ME @ Home Excel Discussion (Misc queries) 1 February 22nd 06 09:49 AM


All times are GMT +1. The time now is 09:46 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"