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

发布网友 发布时间:2022-04-23 03:46

我来回答

2个回答

热心网友 时间:2023-10-13 18:40

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

复制可以吗?

热心网友 时间:2023-10-13 18:41

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

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com