Sub AdjustShapesAspectRatio()

Dim shp As Shape Dim cell As Range

For Each shp In ActiveSheet.Shapes shp.LockAspectRatio = msoFalse 'Unlock aspect ratio Set cell = shp.TopLeftCell 'Get top left cell of shape If Not cell Is Nothing Then 'If shape is within a cell With cell.MergeArea 'Get merged cell range shp.Height = .Height 'Adjust height to match cell shp.Width = .Width 'Adjust width to match cell shp.Left = .Left 'Center horizontally in cell shp.Top = .Top 'Center vertically in cell End With End If Next shp

End Sub

Excel VBA Macro: Center Shapes in Cells and Adjust Aspect Ratio

原文地址: https://www.cveoy.top/t/topic/mAzR 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录