Displaying Graphs

cme044

New Member
Joined
Jul 7, 2011
Messages
5
Just a brief intro to my program. I have a series of userforms, the first one basic data is added and is entered into a spreadsheet. The next one the user chooses which machine they want -there are 5 different machines and depending on which one they choose, another userform -specific to the machine- pops up. After entering data into that userform (which exports the data to the spreadsheet) I want to grab the new results and put it on a graph, which will then display in the next userform.

Currently I can get the graph to a spreadsheet, but I can't get it to display in the userform. I used: ActiveChart.Name = "PDChart" to rename the chart and then replaced the ChartNum with it.. but it didn't work. The code I am using is below.

Any Suggestions?
Thanks
-chels

Private Sub UpdateChart()
Set CurrentChart = Sheets("Chart").PDChart.Chart
CurrentChart.Parent.Width = 470
CurrentChart.Parent.Height = 250

' Save chart as GIF
Fname = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
CurrentChart.Export Filename:=Fname, FilterName:="GIF"
' Show the chart
Image1.Picture = LoadPicture(Fname)
End Sub
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Where you have this code? It might be a scope issue.

I was able to load an image file right into the userform using the UserForm_Initialize call with a simple

Code:
Private Sub UserForm_Initialize()
    Image1.Picture = LoadPicture("C:\Users\Office\Documents\Untitled-1.jpg")
End Sub

Then in the immediate window a UserForm1.show an the image appeared in it.
 
Last edited:
Upvote 0
I was forgetting to call on the UpdateGraph Function, so I can get it to display now. But now, I would like to delete the graph made previously so that it will change the graph that is displayed if I change data. When I start up the program however, there won't be a graph so I can't just say delete it.

Basically I want:

If Graph1 is made Then delete it

Else Continue with program.

I am not sure how to code that properly. .. I am very new with coding.
 
Upvote 0
Also, is there a way to call a Sub (function) from one userform in another? My graphs are not updating unless I close down and start over.
 
Upvote 0
Looks like the code from Walkenbachs book. I'm not that advanced but it seems to be you want the code in a Module and just call it from a forms event.
 
Upvote 0

Forum statistics

Threads
1,224,544
Messages
6,179,430
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top