align shapes

Jyggalag

Active Member
Joined
Mar 8, 2021
Messages
445
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
hi all,

if I have two shapes next to each other that I have attached macros to and I want to align them horizontally, so they don't look silly, how would I do this without manually moving them around forever?

thanks!

Kind regards,
Jyggalag
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
get the shapes roughly level and the hold shown shift and left click on both. Under the drawing tools select align then middle if they are different sizes, or if they are the same size you can use top or bottom (not centre as that overlaps them)
 
Upvote 0
get the shapes roughly level and the hold shown shift and left click on both. Under the drawing tools select align then middle if they are different sizes, or if they are the same size you can use top or bottom (not centre as that overlaps them)
Hi Gordsky,

Thank you very much!

I don't seem to have this option available to me, unless I am missing something?

1644218811347.png
 
Upvote 0
A VBA solution is quite simple. Use whichever line of code gives you what you want.

VBA Code:
Sub AlignShapes()
    ActiveSheet.Shapes.SelectAll
    Selection.ShapeRange.Align msoAlignMiddles, False   '<~~ align by the middle
    'Selection.ShapeRange.Align msoAlignTops, False     '<~~ align by the top
End Sub
 
Upvote 0
In 365 it's on the right hand side of the Shape Format tab.
 
Upvote 0
Solution
later, in the attributes of that shape, say that the format isn't related to the cells (3 possible options there)
 
Upvote 0
A VBA solution is quite simple. Use whichever line of code gives you what you want.

VBA Code:
Sub AlignShapes()
    ActiveSheet.Shapes.SelectAll
    Selection.ShapeRange.Align msoAlignMiddles, False   '<~~ align by the middle
    'Selection.ShapeRange.Align msoAlignTops, False     '<~~ align by the top
End Sub
wow this is crazy nice!!

well done sir :)

very impressive

only downside is that it aligns every shape in my file with each other, so it becomes difficult if you have 10 macros and just want to align 2 of them
 
Upvote 0
In 365 it's on the right hand side of the Shape Format tab.
This works! Thank you so much Rory :) I just had to "align top".

P.S. for anyone reading this thread, remember that you have to manually left click the shape in order for the tab "Shape Format" to appear
 
Upvote 0

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