我已将一些图片插入Sheet2
,我想将它们复制到我的Sheet1
(即ActieSheet)。当我在Sheet1
的第5行之后的column1中键入图像名称时,将执行该图像复制。我尝试了很少的东西,但它们不起作用,但是,我汇集了几行代码或者我希望它实现的方式。这是:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim picName As String
If Target.Column = 1 And Target.Row >= 5 Then
picName = Target.Offset(0, 0).Value
'Here goes the rest of the code
End If
End Sub
任何帮助将不胜感激。感谢
答案 0 :(得分:3)
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Dim picName As String
If Target.Column = 2 And Target.Row >= 5 Then
picName = Target.Value
Copy_Images picName
End If
End Sub
Private Sub Copy_Images(imageName As String)
Dim sh As Shape
For Each sh In Sheets(2).Shapes
If sh.Name = imageName Then
sh.Copy
Sheets(1).Pictures.Paste
End If
Next
End Sub