I do not know much about VBA, so I adapted the following sub to create a special graph.
Sometimes it runs ok but sometimes it crushes, giving an error message at the line with the asterisks.
Is it possible to make it fail-proof?
Thanxx!!
Sometimes it runs ok but sometimes it crushes, giving an error message at the line with the asterisks.
Is it possible to make it fail-proof?
Thanxx!!
Code:
Sub MakePies()
Sheets("Plots1").Select
Sheets("Plots1").Activate
Dim chtMarker As Chart
Dim chtMain As Chart
Dim intPoint As Integer
Dim rngRow As Range
Dim lngPointIndex As Long
ActiveWorkbook.RefreshAll
Sheets("Rslt-Pivots").Calculate
Sheets("Plots1").Calculate
Application.ScreenUpdating = False
Set chtMarker = Sheets("Plots1").ChartObjects("chtPieMarker1").Chart
lngPointIndex = 0
Sheets("Plots1").Activate
Set chtMain = Sheets("Plots1").ChartObjects("graph3").Chart
For Each rngRow In Sheets("Plots1").Range("Ae3:AN19").Rows
chtMarker.SeriesCollection(1).Values = rngRow
chtMarker.Parent.CopyPicture xlScreen, xlPicture
lngPointIndex = lngPointIndex + 1
chtMain.SeriesCollection(1).Points(lngPointIndex).Paste *********
Next
Application.ScreenUpdating = True
End Sub