Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to keep excel from crashing?

Any ideas on how to keep excel from crashing while running the
following? Is asking it to do a for loop with 10 billion iterations
simply too much?

Thanks in advance,

Keith

Private Sub CommandButton1_Click()

Dim StartPrice As Variant
Dim SharesOut As Variant
Dim NewPrice As Variant
Dim Cash As Variant
Dim ATIIPerShare As Variant
Dim PriceApprec As Variant
Dim SharePurch As Variant
Dim MarketCap As Variant
Dim Interest As Variant
Dim Tax As Variant

Cash = 56407000000#
StartPrice = 27.64
SharesOut = 10770000724#
MarketCap = 297876300000#
Interest = 0.05
Tax = 0.33

For SharePurch = 1 To 10770000724#

SharesOut = SharesOut - 1

NewPrice = MarketCap / SharesOut

Cash = Cash - NewPrice

ATIIPerShare = ((Cash * Interest) * (1 - Tax)) / SharesOut

PriceApprec = NewPrice - StartPrice

If ATIIPerShare = PriceApprec Then
MsgBox ("Shares Repurchased = " & SharesPurch & " and New
Cash Balance = " & Cash)
Exit For
End If

Next

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to keep excel from crashing?

I tested this abbreviated version just to be sure (I doubted the number of
the loops in and of itself were problematic)

Private Sub Tester()

Dim StartPrice As Variant
Dim SharesOut As Variant
Dim NewPrice As Variant
Dim Cash As Variant
Dim ATIIPerShare As Variant
Dim PriceApprec As Variant
Dim SharePurch As Variant
Dim MarketCap As Variant
Dim Interest As Variant
Dim Tax As Variant

Cash = 56407000000#
StartPrice = 27.64
SharesOut = 10770000724#
MarketCap = 297876300000#
Interest = 0.05
Tax = 0.33

For SharePurch = 1 To 10770000724#
Next
Debug.Print SharePurch
End Sub

and it ran with no problem

xl2000, win2000

Crash is not very definitive - what happens? If you get an error, what is
it and what line is highlighted?

--
Regards,
Tom Ogilvy

"Keith" wrote in message
om...
Any ideas on how to keep excel from crashing while running the
following? Is asking it to do a for loop with 10 billion iterations
simply too much?

Thanks in advance,

Keith

Private Sub CommandButton1_Click()

Dim StartPrice As Variant
Dim SharesOut As Variant
Dim NewPrice As Variant
Dim Cash As Variant
Dim ATIIPerShare As Variant
Dim PriceApprec As Variant
Dim SharePurch As Variant
Dim MarketCap As Variant
Dim Interest As Variant
Dim Tax As Variant

Cash = 56407000000#
StartPrice = 27.64
SharesOut = 10770000724#
MarketCap = 297876300000#
Interest = 0.05
Tax = 0.33

For SharePurch = 1 To 10770000724#

SharesOut = SharesOut - 1

NewPrice = MarketCap / SharesOut

Cash = Cash - NewPrice

ATIIPerShare = ((Cash * Interest) * (1 - Tax)) / SharesOut

PriceApprec = NewPrice - StartPrice

If ATIIPerShare = PriceApprec Then
MsgBox ("Shares Repurchased = " & SharesPurch & " and New
Cash Balance = " & Cash)
Exit For
End If

Next

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to keep excel from crashing?

Thanks. Excel hangs, and the only way to close Excel is to use Task
Manager. I've given the program an hour to do the calculations, but
it doesn't seem to solve the problem.

Do I need to clear the buffer periodically or something like that? If
so, how do I do this?

Thanks,

Keith
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 691
Default How to keep excel from crashing?

Hi Kevin,
Not enough information. What operating system, what version
of Excel and most important what do you see, and what do you know
that you are not telling us.

What happens if you use Ctrl+break are you looping within a
macro. But take a look at ...
http://www.mvps.org/dmcritchie/excel/slowresp.htm

Clearing your temporary internet files could help.


---
HTH,
David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001]
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Keith" wrote in message om...
Thanks. Excel hangs, and the only way to close Excel is to use Task
Manager. I've given the program an hour to do the calculations, but
it doesn't seem to solve the problem.

Do I need to clear the buffer periodically or something like that? If
so, how do I do this?

Thanks,

Keith



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
Excel Crashing [email protected] Excel Discussion (Misc queries) 1 December 10th 07 02:23 PM
Crashing of Excel FASB Excel Discussion (Misc queries) 1 June 5th 07 04:32 PM
Help--Excel keeps crashing [email protected] Excel Discussion (Misc queries) 1 September 7th 05 10:22 PM
Excel VBA crashing Martin Wheeler Excel Programming 4 February 15th 04 09:05 PM
excel keeps crashing kickyr Excel Programming 4 December 4th 03 09:58 PM


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