ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   How to keep excel from crashing? (https://www.excelbanter.com/excel-programming/303710-how-keep-excel-crashing.html)

Keith[_14_]

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

Tom Ogilvy

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




Keith[_14_]

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

david mcritchie

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





All times are GMT +1. The time now is 11:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com