Resize object based on formula and maintain aspect ratio

IanA

New Member
Joined
Apr 19, 2021
Messages
3
Office Version
  1. 2010
Platform
  1. Windows
Hi, I have followed the YouTube tip below to create a resized object based on the results of a formula.


It works pretty well, but I want to ensure the aspect ratio of the object is maintained as a perfect square.

I've used the below but for some reason even though the width and height are referencing a value in the same cell the aspect ratio doesn't stay constant

With ActiveSheet.Shapes.Range(Array("square1"))
.Width = Range("B3").Value
.Height = Range("B3").Value
End With

Any thoughts?
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try controlling the "aspect ratio":
Code:
With ActiveSheet.Shapes.Range(Array("square1"))
    .LockAspectRatio = msoFalse
    .Width = Range("B3").Value
    .Height = Range("B3").Value
End With
Or, if the starting shape is a perfect square, set .LockAspectRatio = msoTrue and assign only the new Width (Height will resize maintaining the aspect ratio)

Bye
 
Upvote 0
Try controlling the "aspect ratio":
Code:
With ActiveSheet.Shapes.Range(Array("square1"))
    .LockAspectRatio = msoFalse
    .Width = Range("B3").Value
    .Height = Range("B3").Value
End With
Or, if the starting shape is a perfect square, set .LockAspectRatio = msoTrue and assign only the new Width (Height will resize maintaining the aspect ratio)

Bye
Thank you. I'll give it a go
 
Upvote 0
Although the control for aspect ratio provided by Anthony47 was a useful build it didn't resolve the problem.
After further investigation it appears the issue lies in the fact that objects exist in another layer on the worksheet and when zooming in and out, scaling of this layer is affected, hence the dimensions of the object appear to change. When returning to 100% zoom however height and width return to the correct aspect ratio and if saved out as a pdf relative dimensions of objects are correct.
 
Upvote 0
Solution

Forum statistics

Threads
1,214,823
Messages
6,121,779
Members
449,049
Latest member
greyangel23

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