Auto Resizing Shape between specified cells Rows & Columns VBA

Hayf13

New Member
Joined
Jul 27, 2021
Messages
10
Office Version
  1. 365
Platform
  1. Windows
Hey Gang! Hope all is well, hoping for a little help - had a macro set up to generate some signs and autosize in a set pattern which worked perfectly on my laptop - however noticed when moving to a different screen ratio this didn't return the results I was hoping for - so wondering if it's possible to automatically resize the selected shape between two distinct cells (In my case to the upper left of cell U4 &Lower right of cell Z13)

' testphoto Macro
'

Selection.ShapeRange.Name = "displayphoto"
Selection.Name = "displayphoto"

'FIND WAY TO RESIZE/FIT SHAPE BETWEEN UPPER LEFT OF U4 AND LOWER RIGHT OF Z13
'MAYBE Selection.ShapeRange.ScaleWidth ??
' Selection.ShapeRange.ScaleHeight ??


Selection.ShapeRange.LockAspectRatio = msoFalse

Application.CommandBars("Format Object").Visible = False

Call pricesigncreator


What was working fine on laptop was when I had defined pixel heights etc - any help would be marvellous!

Cheers all
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
I did it! Posting the answer here incase it helps someone else - was as simple as defining the width/lengths as ranges.....days that took. D'oh

MyRange = ("U4:Z13")
Selection.ShapeRange.Name = "displayphoto"
Selection.Name = "displayphoto"


With Selection.ShapeRange
.LockAspectRatio = msoFalse
.Width = Range(MyRange).Width
.Height = Range(MyRange).Height


With Selection
.Placement = xlMoveAndSize
.PrintObject = True
End With



Call pricesigncreator
 
Upvote 0
Solution

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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