Boogerbut74
New Member
- Joined
- Oct 17, 2022
- Messages
- 26
- Office Version
- 365
- Platform
- Windows
I'm trying to set the legend below the x axis and to set a min and max for the x and y axis
VBA Code:
Sub base_graph_creator()
'Your data range for the chart
Dim rng As Range
Dim cht As ChartObject
Set rng = ActiveSheet.Range("D10:V2363")
'Create a chart
Set cht = ActiveSheet.ChartObjects.Add( _
Left:=ActiveCell.Left, _
Width:=450, _
Top:=ActiveCell.Top, _
Height:=250)
'Give chart some data
cht.Chart.SetSourceData Source:=rng
'Determine the chart type
cht.Chart.ChartType = xlXYScatterLines
' this makes the x axis min and max
cht.Chart.Axes(xlCategory).MinimumScale = 0
cht.Chart.Axes(xlCategory).MaximumScale = 100
' this makes the y axis min and max
ActiveChart.Chart.Axes(ylCategory).MinimumScale = 115
ActiveChart.Chart.Axes(ylCategory).MaximumScale = 140
' this changes legend position
ActiveChart.Legend.Position = xlLegendPositionBottom