I have been researching the modes of displaying charts in a userform.
The general consensus seems to be to save the chart as a .GIF file and then upload this within the
Case 1: If the chart is on the worksheet, it will be easier as below:
Private Sub UserForm_Initialize()
Dim Fname As String
Call SaveChart
Fname = ThisWorkbook.Path & "\temp1.gif"
Me.Image1.Picture = LoadPicture(Fname)
End Sub
Private Sub SaveChart()
Dim MyChart As Chart
Dim Fname As String
Set MyChart = Sheets("Data").ChartObjects(1).Chart
Fname = ThisWorkbook.Path & "\temp1.gif"
MyChart.Export Filename:=Fname, FilterName:="GIF"
End Sub
Case 2: If chart is not on the worksheet, you may need to create a temporary chart, save it as GIF, delete it, and finally load the picture {
Me.Image1.Picture = LoadPicture(Fname)
} when the Userform is initialized.
Case 1 is easier to code. The above code still works even I cut and paste the chart in a later-hidden worksheet.