Okay, I've recreated the problem with a relatively simple program:
This program is in 3 parts:
1) A Module :"Module 1"
2) A UserForm: "UserForm1"
3) A Class: "Graphing"
Code in Module 1:
Public Sub runTest()
Dim myForm As UserForm1
Set myForm = New UserForm1
myForm.Show
End Sub
Code in UserForm1
Private myGraphing As Graphing
Private Sub UserForm_Initialize()
Set myGraphing = New Graphing
End Sub
Private Sub CommandButton1_Click()
Call myGraphing.mainGraph
End Sub
Code in Graphing
Private count As Integer
Private Sub class_initialize()
count = 1
End Sub
Public Function mainGraph()
Sheets("Sheet1").Select
Call makeGraph
Call deleteChart
Sheets("Sheet1").Select
Call saveTest
Call makeGraph
Call deleteChart
Sheets("Sheet1").Select
End Function
Private Function makeGraph()
'
' makeGraph Macro
Range("A1:B13").Select
ActiveSheet.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:=Range("Sheet1!$A$1:$B$13")
ActiveChart.ChartType = xlColumnClustered
ActiveChart.SeriesCollection(1).Delete
ActiveChart.SeriesCollection(1).XValues = "=Sheet1!$A$1:$A$13"
ActiveChart.Location Where:=xlLocationAsNewSheet
End Function
Private Function saveTest()
Application.DisplayAlerts = False
Application.ActiveWorkbook.SaveCopyAs Filename:="TestReport.xlsm"
Application.DisplayAlerts = True
End Function
Private Function deleteChart()
Application.DisplayAlerts = False
ActiveChart.Delete
Application.DisplayAlerts = True
End Function
Okay in Sheets1 I have values in a1 through b13 (this is where the graph grabs its values from)
A B
0 43
1 73
2 22
3 34
4 22
5 76
6 74
7 45
8 73
9 34
10 72
11 52
12 32
If you throw in a code break and follow the code, it fails at the same part as in my program: which is at the location method.
any help would be greatly appreciated
Bookmarks