image align and distribute

rjplante

Well-known Member
Joined
Oct 31, 2008
Messages
574
Office Version
  1. 365
Platform
  1. Windows
I have a page with several images/icons on it that I have created into buttons. I would like to write a short macro to align the centers of the images as they are in a column and then to distribute them vertically. Is there an easy way to do this?

Thanks,

Robert
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Maybe something like this...

<font face=Calibri><SPAN style="color:#00007F">Option</SPAN> <SPAN style="color:#00007F">Explicit</SPAN><br><br><SPAN style="color:#00007F">Sub</SPAN> test()<br><br>    <SPAN style="color:#00007F">Dim</SPAN> MyGroup <SPAN style="color:#00007F">As</SPAN> Shape<br>    <SPAN style="color:#00007F">Dim</SPAN> ColumnWidth <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Variant</SPAN><br>    <SPAN style="color:#00007F">Dim</SPAN> GroupWidth <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Single</SPAN><br><br>    ActiveSheet.Shapes.Range(Array("Picture 1", "Picture 2", "Picture 3")).Select <SPAN style="color:#007F00">'or ActiveSheet.Shapes.SelectAll</SPAN><br><br>    <SPAN style="color:#00007F">With</SPAN> Selection.ShapeRange<br>        .Align msoAlignCenters, <SPAN style="color:#00007F">False</SPAN><br>        .Distribute msoDistributeVertically, <SPAN style="color:#00007F">False</SPAN><br>        <SPAN style="color:#00007F">Set</SPAN> MyGroup = .Group<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">With</SPAN><br>    <br>    ColumnWidth = MyGroup.TopLeftCell.Width<br>    <br>    GroupWidth = MyGroup.Width<br>    <br>    MyGroup.Left = (ColumnWidth - GroupWidth) / 2<br>    <br>    MyGroup.Ungroup<br>        <br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br></FONT>
 
Upvote 0

Forum statistics

Threads
1,224,542
Messages
6,179,421
Members
452,913
Latest member
JWD210

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