![]() |
how do I use a macro to center a shape in a cell in excel
Just that! I have a macro that copies various data to create a formatted
sheet, and I want a shape to be centered vertically and horizontally within the cell after the cell is resized. Problem at present is that the shape retains its alignment with the top border of the cell when the cell is resized. I want to be able to center it. |
how do I use a macro to center a shape in a cell in excel
Got it!
Get the cell top and left properties; as well as the cell width and height and the object width and height, then do this: ActiveSheet.Shapes("Group 141").Select 'get the object With Selection .Left = Range("B23").Left + (Range("B23").Width - Selection.Width) / 2 .Top = Range("B23").Top + (Range("B23").Height - Selection.Height) / 2 End With "ElectroAeroguy" wrote: Just that! I have a macro that copies various data to create a formatted sheet, and I want a shape to be centered vertically and horizontally within the cell after the cell is resized. Problem at present is that the shape retains its alignment with the top border of the cell when the cell is resized. I want to be able to center it. |
All times are GMT +1. The time now is 10:08 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com