您的一个点赞,一句留言,一次打赏,就是小编创作的动力源泉!
转载须注明原作者及出处!》》》打赏直通车
1.情景展示
如何将批量插入的图片自适应单元格大小?

2.解决方案
实现方式:通过宏命令实现。
ALT+F11-->打开VBA编辑器-->插入-->模块;

将下列代码拷贝至弹出的窗口:
Sub 图片适应单元格()
'声明图形对象变量
Dim sh As Shape
'遍历本所有图形对象
For Each sh In ActiveSheet.Shapes
'让图片的高度、宽度都允许修改(不锁定长宽比)
sh.LockAspectRatio = False
'调整左边距
sh.Left = sh.TopLeftCell.Left
'调整上边距
sh.Top = sh.TopLeftCell.Top
'调整宽度
sh.Width = sh.TopLeftCell.Width
'调整高度
sh.Height = sh.TopLeftCell.Height
Next sh
End Sub
按F5运行--》运行;

3.效果展示
所有的图片的大小=单元格的大小

将其移至各个单元格。

相关推荐

网友评论