一、选中需要居中的图片(ALT+A全选)
二、按ALT+F11打开Microsoft Visual Basic for Applications窗口:
1、点击:插入-模块:
2、输入代码:
Sub dq() Dim shp As Shape For Each shp In ActiveSheet.Shapes shp.Left = (shp.TopLeftCell.Width - shp.Width) / 2 + shp.TopLeftCell.Left shp.Top = (shp.TopLeftCell.Height - shp.Height) / 2 + shp.TopLeftCell.Top Next End Sub
3、直接关闭窗口。
三、按ALT+F8,打开宏命令窗口:
四、执行dq宏命令。
五、完。
标签:居中,shp,Sub,单元格,Excel,TopLeftCell,插入,ALT From: https://www.cnblogs.com/tolerate/p/17513282.html