Av8tordude
Well-known Member
- Joined
- Oct 13, 2007
- Messages
- 1,075
- Office Version
- 2019
- Platform
- Windows
I have a userform with labels (Label1.Caption = Store-1 & Label2.Caption = Store-2) I want to display on the Chart Legend. I would like to the Chart legend to display the captions of each label. How can I accomplish this?
i.e.
Legend 1 = Label1.Caption
Legend 2 = Label2.Caption
Also, my code is display my headers when if my cell selection is 1 step below. If I select any other cells 2 steps below it, then the graph is display. Is there a way this can be avoided showing my headers.
THank you for your assistance
i.e.
Legend 1 = Label1.Caption
Legend 2 = Label2.Caption
Also, my code is display my headers when if my cell selection is 1 step below. If I select any other cells 2 steps below it, then the graph is display. Is there a way this can be avoided showing my headers.
THank you for your assistance
Code:
Sub MyChart()Dim MyChart As Chart
Dim CurrentChart As Object
Dim ChartName As String
Dim fname As String
Dim ChartNum As Integer
Range("Y1") = tbFctr.Value
Range("Z1") = 1
Set MyChart = ActiveSheet.Shapes.AddChart(xlPie).Chart
MyChart.SeriesCollection.NewSeries
MyChart.SeriesCollection(1).Values = Range("Y1:Z1")
With MyChart
.ChartArea.Height = 90
.ChartArea.Width = 120
.ChartStyle = 42
End With
fname = Application.DefaultFilePath & Application.PathSeparator & "TempChart.gif"
MyChart.Export Filename:=fname, FilterName:="GIF"
frmRisk.Image.Picture = LoadPicture(fname)
ActiveSheet.ChartObjects(1).Delete
Kill fname
Application.EnableEvents = False
Range("Y1").ClearContents
Range("Z1").ClearContents
Application.EnableEvents = True
End Sub