假设我有三张图片分别为“太阳”,“月亮”,“星星”;在excel里,我想在A1中分别输入“太阳”,“月亮”

2020-04-17 社会 150阅读
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column <> 1 And Target.Row <> 1 Then Exit Sub
On Error Resume Next
Dim ph As String
With ActiveSheet
ph = ThisWorkbook.Path & "\" & Target & ".jpg" '图片地址,跟excel文件相同
.Pictures("pic").Delete
.Pictures.Insert(ph).Name = "pic"
.Pictures("pic").Top = Cells(1, 2).Top
.Pictures("pic").Left = Cells(1, 2).Left
End With
声明:你问我答网所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系fangmu6661024@163.com