LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default Sub Exits Unexpectedly

I thought that I would get an error though. I only use an On errror
Resume Next statement once but have On Error Goto 0 two lines down. I

still
don't see how the Sub just quits but thank you very much for the help.


Do you have "break on all errors" set in the VB Editor ?

Tim


--
Tim Williams
Palo Alto, CA


"Walker" wrote in message
...
I figured it out. Once I changed my .text to .value I was jumping out

because
of div/0, so I put a statement to omit the calc if either value = 0 and

it
works. I thought that I would get an error though. I only use an On

errror
Resume Next statement once but have On Error Goto 0 two lines down. I

still
don't see how the Sub just quits but thank you very much for the help.

"Walker" wrote:

Okay I changed all my .text to .value and that fixed some of them and I

put a
message box after each select Case to let me know it finished. I ran

through
all of the combobox options and found that whenever it encounters a 0 it
jumps out. the text box has 0 in it and when i jump through the code it

shows
Variable = "0" which shouldn't be interpreted as a null. I put an if x

= 0
then x = 0 statement and the if is triggered but the sub just quits.

When I
step through it jumps out right after the calculation in the previous

select
case; I don't even get the msgbox that the previous one finished but the
calculation is on the userform. I can't figure out why or even how the

sub
jumps out.

"K Dales" wrote:

A Sub can't just jump out like that, so the code must be executing,

but not
having any effect you can see. For example, if you put a MsgBox "I AM

HERE!"
just before your End Sub line, I am sure you will get the message box

when
the sub is called. So there must be something else you are seeing -

or not
seeing.

You are subtracting two numbers and checking if the result is less

than
zero, zero, or greater than zero. This seems fine but there is one

other
possible result: if the result is Null. It is possible to get a Null

result
from a subtraction if either or both values being subtracted are Null;

e.g.
5-Null = Null and Null-Null = Null. I would put a breakpoint in the

code
just before your Select Case statements that do not seem to be

functioning,
and then when in debug mode check what the values actually are. Try
? CPU501.Value in the immediate pane, as well as ? CPU502.Value and ?
CPU501.Value - CPU502.Value. If you are getting Nulls add that as

another
case to your Select Case statement. Same thing for the other Select

Case.
--
- K Dales





 
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
Prompt msg if the worksheet already exits Dee New Users to Excel 2 November 7th 08 05:11 PM
Find if value exits in array Glynn Excel Worksheet Functions 6 September 5th 08 08:46 PM
excel exits unexpectedly or hangs the second time I open workbook r_m_i Excel Discussion (Misc queries) 0 February 9th 06 10:14 PM
way to run sub after user exits textbox funkymonkUK[_50_] Excel Programming 2 July 12th 05 01:10 PM
graceful exits Bryan[_12_] Excel Programming 3 November 23rd 04 07:56 PM


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