PDA

View Full Version : How to assign Xaxis limits to multiple scatter plots on the same sheet?



stanhilliard
10-03-2021, 07:49 PM
I have ten scatter plots on the same worksheet tab named Multiples. The charts will all have the same x-axis limits. I want to set the limits with VBA. The x-axis limits are in calculated variables named vXaxisL and vXaxisU.

I don't know how to address each chart from VBA nor how to assign the limits to the individual charts.

Office Professional 2016 Excel/VBA. Windows 10

mana
10-09-2021, 11:27 PM
Dim ws As Worksheet
Dim cho As ChartObject
Dim aX As Axis

Set ws = ActiveSheet
For Each cho In ws.ChartObjects
Set aX = cho.Chart.Axes(xlCategory)
aX.MinimumScale = vXaxisL
aX.MaximumScale = vXaxisU
Next