Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

How to specify Y-axis Maximum Value in Excel Chart?

$
0
0

I wrote the following code to create a chart in Excel, but I need to specify that the Y Axis be fixed at 100 instead of set to the default of Auto.

# Generate graph
$xRow =1
$yRow = $rows
$objRange=$Worksheet.range("a${xRow}:c${yRow}")
$colCharts=$excel.Charts
$objChart=$colCharts.Add()
$objChart.ChartType=4
$objChart.Axes(0).CategoryType=2
$objChart.Axes(0).TickLabelSpacing=7
$objChart.HasTitle= $true
$objChart.ChartTitle.text ="Report"
$a=$objChart.Activate

So to clarify, if the maximum value the chart needs to draw is about 66 then the Y-axis will by default set itself to 70 but I need it to be 100 regardless.

I've tried $objChart.Axes(0).Maximum = 100 and also .Minimum and .MaximumScaling and .Scaling.Maximum but none of these have worked. Does anyone know the correct command?

Thanks in advance


Viewing all articles
Browse latest Browse all 6937

Trending Articles