Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how do I create multiple scatter charts on a userform with each chart having one series colletion and display it as an image.I have tried coding thou it has errors. This is the code

What I have tried:

Private Sub CommandButton1_Click()
If ComboBox1.Text = "Select a chart" Then

MsgBox "Select a chart from the dropdown list"
Exit Sub

End If

Dim i As Integer

i = 0
For Each ChartObjects In ThisWorkbook.Worksheets(target).ChartObjects
If i = 0 Then
ChartObjects.Chart.SeriesCollection(1).Values = "=" & target & "!$Y$6:$Y$1048570"
ChartObjects.Chart.SeriesCollection(2).Values = "=" & target & "!$M$6:$M$1048570"
ElseIf i = 1 Then
ChartObjects.Chart.SeriesCollection(1).Values = "=" & target & "!$K$6:$K$1048570"
ChartObjects.Chart.SeriesCollection(2).Values = "=" & target & "!$M$6:$M$1048570"
ElseIf i = 2 Then
ChartObjects.Chart.SeriesCollection(1).Values = "=" & target & "!$L$6:$L$1048570"
ChartObjects.Chart.SeriesCollection(2).Values = "=" & target & "!$M$6:$M$1048570"
End If
i = i + 1
Next


Dim imageName As String
imageName = Application.DefaultFilePath & Application.PathSeparator & "TempChart.gif"
MyChart.Export Filename:=imageName
ActiveSheet.ChartObjects(1).Delete
Application.ScreenUpdating = True
UserForm1.Image1.Picture = LoadPicture(imageName)

End Sub

Private Sub Image1_Click()

End Sub

Private Sub UserForm_Click()

End Sub

Private Sub UserForm_Initialize()
ComboBox1.AddItem ("IRR")
ComboBox1.AddItem ("Value At Risk")
ComboBox1.AddItem ("Current Fund Credit")
End Sub
Posted
Comments
Patrice T 14-Jun-16 3:04am    
Which error message ? where ?
Member 12582308 14-Jun-16 3:23am    
the errors pop up when running this part of the code

ActiveSheet.ChartObjects(1).Delete
Application.ScreenUpdating = True
Patrice T 14-Jun-16 3:26am    
Use Improve question to update your question.
So that everyone can pay attention to this information.
Member 12582308 14-Jun-16 3:27am    
okey thanks,let me do just that

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900