Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 389
Default Application.InputBox

I have the following code:

vAmount = ActiveCell.Value
Dim EnterAmount As Variant
EnterAmount = InputBox("Enter the amount to Hardcode: ", , vAmount)
If EnterAmount < "" Then
ActiveCell.Value = EnterAmount
End If

Now if I hit cancel the amount will remain what it was.

But if I use Application.InputBox:
EnterAmount = Application.InputBox("Enter the amount to Hardcode: ", ,
vAmount, , , , , Type:=1)
then if I hit Cancel I will get a False in the cell. How do I make it so
if I hit Cancel with using the Application.Input box the cell will not change
to False but will remain what the cell was when I entered the cell like the
InputBox does.


Thank you for your help,

Steven

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Application.InputBox

Dim EnterAmount As Variant

EnterAmount = Application.InputBox(Prompt:="Enter the amount to Hardcode:", _
Type:=1)

If EnterAmount = False Then
'what should happen?
Else
'do the real work
activecell.value = enteramount
end if

Steven wrote:

I have the following code:

vAmount = ActiveCell.Value
Dim EnterAmount As Variant
EnterAmount = InputBox("Enter the amount to Hardcode: ", , vAmount)
If EnterAmount < "" Then
ActiveCell.Value = EnterAmount
End If

Now if I hit cancel the amount will remain what it was.

But if I use Application.InputBox:
EnterAmount = Application.InputBox("Enter the amount to Hardcode: ", ,
vAmount, , , , , Type:=1)
then if I hit Cancel I will get a False in the cell. How do I make it so
if I hit Cancel with using the Application.Input box the cell will not change
to False but will remain what the cell was when I entered the cell like the
InputBox does.

Thank you for your help,

Steven


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default Application.InputBox

Dave showed you the code. The explanation is that for InputBox function,
cancel equals "". For InputBox Method, cancel equals "False". So if you use
Application.InputBut you have to change your "If" statement to match whatever
cancel equals.

"Dave Peterson" wrote:

Dim EnterAmount As Variant

EnterAmount = Application.InputBox(Prompt:="Enter the amount to Hardcode:", _
Type:=1)

If EnterAmount = False Then
'what should happen?
Else
'do the real work
activecell.value = enteramount
end if

Steven wrote:

I have the following code:

vAmount = ActiveCell.Value
Dim EnterAmount As Variant
EnterAmount = InputBox("Enter the amount to Hardcode: ", , vAmount)
If EnterAmount < "" Then
ActiveCell.Value = EnterAmount
End If

Now if I hit cancel the amount will remain what it was.

But if I use Application.InputBox:
EnterAmount = Application.InputBox("Enter the amount to Hardcode: ", ,
vAmount, , , , , Type:=1)
then if I hit Cancel I will get a False in the cell. How do I make it so
if I hit Cancel with using the Application.Input box the cell will not change
to False but will remain what the cell was when I entered the cell like the
InputBox does.

Thank you for your help,

Steven


--

Dave Peterson

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
application.inputbox Christmas May[_2_] Excel Programming 5 November 22nd 06 04:11 PM
Inputbox and Application.InputBox Maria[_7_] Excel Programming 1 September 20th 04 11:36 AM
inputbox and application.run macro1 Michael Joe Excel Programming 3 August 13th 04 09:34 PM
application.inputbox Murat Excel Programming 4 February 24th 04 11:38 AM
Application.Inputbox Question ndp Excel Programming 3 December 8th 03 06:12 PM


All times are GMT +1. The time now is 09:30 AM.

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

About Us

"It's about Microsoft Excel"