PC Review


Reply
Thread Tools Rate Thread

Application.InputBox

 
 
=?Utf-8?B?U3RldmVu?=
Guest
Posts: n/a
 
      23rd Dec 2006
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

 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      23rd Dec 2006
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 With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      23rd Dec 2006
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 With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Application.InputBox(,,,,,8) JsJ_Slim Microsoft Excel Programming 3 8th Aug 2008 02:32 AM
application.inputbox =?Utf-8?B?Q2hyaXN0bWFzIE1heQ==?= Microsoft Excel Programming 5 22nd Nov 2006 04:11 PM
Inputbox and Application.InputBox Maria Microsoft Excel Programming 1 20th Sep 2004 11:36 AM
inputbox and application.run macro1 Michael Joe Microsoft Excel Programming 3 13th Aug 2004 09:34 PM
application.inputbox Murat Microsoft Excel Programming 4 24th Feb 2004 11:38 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:36 PM.