1

我已经插入了一些图像Sheet2,我想将它们复制到我的Sheet1(即 ActieSheet)中。当我在第 5 行之后的 column1 中键入图像名称时,将执行该图像副本Sheet1。我尝试了一些东西,但它们不起作用,但是,我已经组装了几行代码或我希望它实现的方式。这里是:

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

任何帮助将不胜感激。谢谢

4

1 回答 1

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
于 2013-06-10T12:14:33.927 回答