|
本帖最后由 279517904 于 2023-4-26 15:33 编辑
需要根据编号单元格(AJ35)变化批量插入名为”图片“文件夹内BMP图片,图片插入后的范围是g48:w62
现在想在a233:q237范围内也插入相同的图片,应该怎样修改?
原有如下:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range, fp$, shnm$, nm$, shp As Shape
Dim tp, lf, wd
Set rng = [g48:w62]
If Target.Count > 1 Then Exit Sub
If Target = "" Then Exit Sub
If Target.Address <> "$AJ$35" Then Exit Sub
fp = ThisWorkbook.Path & "\图片\"
nm = fp & "\" & Target.Value & ".bmp"
For Each shp In ActiveSheet.Shapes
If shp.Type = msoAutoShape Then
shp.Delete
End If
Next
nn = Dir(nm)
If nn <> "" Then
With rng
ML = .Left
MT = .Top
MW = .Width
MH = .Height
ActiveSheet.Shapes.AddShape(msoShapeRectangle, ML, MT, MW, MH).Select
Selection.ShapeRange.Fill.UserPicture nm
End With
End If
Target.Select
End Sub
在a233:q237范围内也插入相同的图片,附件已上传
|
|