Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 138
Default My Macro crashes excel - anyone know why.

I have a macro that does some chart formatting but crashes Excel with the
following error.

"Microsoft Excel for Windows has encountered a problem and needs to close.
We are sorry for the inconvenience"

Very occaisionally it will complete succuessfully (10% of the time), but I
have no idea why it does it. I am running Excel 2000 SP3 and have tried on
other machines with the same result.

Is it poor programming somewhere, see code below;

Bruce

--------------------------------------------------------------------------------------------

Sub myEquityCurve()

Application.ScreenUpdating = False

Dim myArray
Dim myVar1(1 To 4)
Dim myChart(1 To 4)
ReDim myArray(1 To 4)

myEC = "EC"

'Variables
myArray = Array("Sec1", "Sec2", "Sec3", "Sec4")

myVar1(1) = "D10"
myVar1(2) = "F10"
myVar1(3) = "H10"
myVar1(4) = "J10"

myChart(1) = "Chart 1"
myChart(2) = "Chart 3"
myChart(3) = "Chart 4"
myChart(4) = "Chart 5"

'Start Code

Sheets(myEC).Select
Range("A1").Select

k = 1
For Each d In myArray

'Find the row number
c = Format(Sheets("Shares").Range(myVar1(k)), "yyyymmdd")

With Worksheets(d).Range("A1:A1000")
Set a = .Find(c, LookIn:=xlValues)
b = a.Row
mySec = Worksheets(d).Range("B2")
End With

If mySec = "" Then
GoTo Skip
End If

'Update Graph
With Sheets(myEC)
.ChartObjects(myChart(k)).Activate
ActiveChart.ChartTitle.Characters.text = "EC - " & mySec
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).XValues =
Sheets(d).Range("I2:I" & b)
ActiveChart.SeriesCollection(1).Values =
Sheets(d).Range("H2:H" & b)

End With

k = k + 1
Skip:
Next d
Range("A1").Select

'Finish
Sheets("Update").Select
Application.ScreenUpdating = False

End Sub

-----------------------------------------------------------------------------------------



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
Macro Crashes ineedhelp2[_3_] Excel Programming 1 August 18th 05 02:06 AM
Excel macro crashes when it sets a cell formula Dr Rubick Excel Programming 7 April 12th 05 04:28 PM
Macro crashes if I run it twice Please Help Excel Programming 4 January 26th 05 10:53 PM
Excel crashes on close - macro related Bert[_3_] Excel Programming 0 July 23rd 04 01:56 PM
Excel VBA - Excel crashes when macro button re-assigned problem PaulC Excel Programming 6 April 17th 04 08:57 PM


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