Userform Label on Chart Label

Av8tordude

Well-known Member
Joined
Oct 13, 2007
Messages
1,075
Office Version
  1. 2019
Platform
  1. 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

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
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,224,823
Messages
6,181,171
Members
453,021
Latest member
Justyna P

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