ChartArea.width sometimes rounded

VbaMinion

New Member
Joined
Jul 14, 2017
Messages
2
Hi all,
I have a simple command in my macro which should change a width of my chart to 23cm. But for some charts it works and for some other charts it changes its width to 23.17cm. I have checked the properties of both charts and didn't find any difference.

Code:
ActiveChart.ChartArea.Width=647

I have tried

Code:
ActiveChart.Parent.Width=647

but it didn't help.

Does anyone had any idea why?
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Welcome to the Forum


Code:
Sub Minion()
Dim co As ChartObject
Set co = ActiveChart.Parent
co.Chart.ChartArea.AutoScaleFont = 0
co.Width = Application.CentimetersToPoints(23)
End Sub
 
Upvote 0
Still didn't work, but I have tried this and it does the trick:

Code:
Sub Minion()
dim Standard_Exterior_Width as double
Standard_Exterior_Width=[COLOR=#333333]Application.CentimetersToPoints(23)[/COLOR]
        ActiveChart.ChartArea.Width = [COLOR=#333333]Application.CentimetersToPoints(23)[/COLOR]
        Do While ActiveChart.ChartArea.Width > [COLOR=#333333]Application.CentimetersToPoints(23)[/COLOR]
            ActiveChart.ChartArea.Width = Standard_Exterior_Width
            Standard_Exterior_Width = Standard_Exterior_Width - 1
        Loop
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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