how do I use a macro to center a shape in a cell in excel

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
Back
Top