Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Getting 0 to not equal False


Hi,
I have a macro that is supposed to prompt for some data. If the use
hits cancel, I would like the macro to end. However, if the use
inputs 0 (the default), I need the macro to continue running.
Unfortunately, right now the macro is ending if you hit cancel, o
input 0 and hit OK. Any suggestions would be much appreciated.
Thanks.

My code:
Dim Depreciation
Depreciation = Application.InputBox(prompt:="Depreciation?"
Default:=Range("p5"), Type:=1)
If Depreciation = False Then
End
Else
Range("P5").Select
ActiveCell.FormulaR1C1 = _
Depreciation
End I

--
mkerste
-----------------------------------------------------------------------
mkerstei's Profile: http://www.excelforum.com/member.php...fo&userid=2568
View this thread: http://www.excelforum.com/showthread.php?threadid=55745

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,069
Default Getting 0 to not equal False


On the line

If Depreciation = False Then

put False in double quotes:

If Depreciation = "False" Then

Hope this helps,

Hutch
--
"mkerstei" wrote:


Hi,
I have a macro that is supposed to prompt for some data. If the user
hits cancel, I would like the macro to end. However, if the user
inputs 0 (the default), I need the macro to continue running.
Unfortunately, right now the macro is ending if you hit cancel, or
input 0 and hit OK. Any suggestions would be much appreciated.
Thanks.

My code:
Dim Depreciation
Depreciation = Application.InputBox(prompt:="Depreciation?",
Default:=Range("p5"), Type:=1)
If Depreciation = False Then
End
Else
Range("P5").Select
ActiveCell.FormulaR1C1 = _
Depreciation
End If


--
mkerstei
------------------------------------------------------------------------
mkerstei's Profile: http://www.excelforum.com/member.php...o&userid=25688
View this thread: http://www.excelforum.com/showthread...hreadid=557455


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Getting 0 to not equal False

I think you're mistaken.

I bet that the user hit entering the 0, but hitting the cancel button.

And I think I'd change that "End" statement to "exit sub"

End statements can cause trouble that may be difficult to debug later.

mkerstei wrote:

Hi,
I have a macro that is supposed to prompt for some data. If the user
hits cancel, I would like the macro to end. However, if the user
inputs 0 (the default), I need the macro to continue running.
Unfortunately, right now the macro is ending if you hit cancel, or
input 0 and hit OK. Any suggestions would be much appreciated.
Thanks.

My code:
Dim Depreciation
Depreciation = Application.InputBox(prompt:="Depreciation?",
Default:=Range("p5"), Type:=1)
If Depreciation = False Then
End
Else
Range("P5").Select
ActiveCell.FormulaR1C1 = _
Depreciation
End If

--
mkerstei
------------------------------------------------------------------------
mkerstei's Profile: http://www.excelforum.com/member.php...o&userid=25688
View this thread: http://www.excelforum.com/showthread...hreadid=557455


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Getting 0 to not equal False


Hmm...I put quotations around 'False' as well as replaced 'End' with
'Exit Sub'.
Unfortunately, the problem persists. If I type any number besides 0
and hit enter, the macro will continue, but entering '0' will end the
sub. Any other suggestions?


--
mkerstei
------------------------------------------------------------------------
mkerstei's Profile: http://www.excelforum.com/member.php...o&userid=25688
View this thread: http://www.excelforum.com/showthread...hreadid=557455

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Getting 0 to not equal False


Yeah, I totally put the quotes in a lower part of the macro, so
obviously the macro never had a chance to test the "False". It worked,
and it was so simple I'm embarassed. Thank you very much Hutch!


--
mkerstei
------------------------------------------------------------------------
mkerstei's Profile: http://www.excelforum.com/member.php...o&userid=25688
View this thread: http://www.excelforum.com/showthread...hreadid=557455

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
can I make cell "yes" equal 1, "no" equal 0 can I make cell yes equal 1, no equa Excel Discussion (Misc queries) 4 April 22nd 23 06:09 AM
Data displayed that is not equal to FALSE in a row Mally Excel Discussion (Misc queries) 3 February 11th 10 12:36 PM
What's the best way to toggle between true and false in Excel? Hiall, My excel work involves a lot of toggling between true and false (booleantypes) ... and it's very repetitive... Is there a way to select a bunch ofcells, and press a key short-cu LunaMoon Excel Discussion (Misc queries) 9 July 29th 08 12:28 AM
lower and upper case equal on spreadsheet but not equal in VB don Excel Programming 2 March 13th 05 12:04 AM
True Or False, no matter what... it still displays the false statement rocky640[_2_] Excel Programming 2 May 13th 04 04:57 PM


All times are GMT +1. The time now is 10:40 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"