lpking2005
Board Regular
- Joined
- Mar 21, 2011
- Messages
- 140
hi, currently i have some code which copy/pastes an image from a workbook into another workbook when I input a order number into Cell (J21)
The problem is that when I insert a different order number, all it does is paste another image on top of the existing image.
I need it to delete the existing picture first before receiving new image and delete the existing picture when Cell (J21) is empty.
Here is the code i am using:
Private Sub Worksheet_Change(ByVal Target As Range)
'paste image from matrix
If Not Intersect(Target, Range("J21", "K22")) Is Nothing Then
If Range("J21").Value <> "" Then
SKU = Range("M23").Value
Workbooks.Open "T:\Production\PROD MOULDING\2 - LINE MANUAL PROJECT\Mouldings Product_Labour Matrix.xls", 0, 1
With Sheets("403").Shapes("" & SKU & "")
.Height = 301
.Width = 101
.Copy
End With
ThisWorkbook.Activate
Sheets("HOME PAGE").Range("Q27").PasteSpecial
With Application
.DisplayAlerts = False
Windows("Mouldings Product_Labour Matrix.xls").Close
.DisplayAlerts = True
End With
Else
'delete shape
End If
End If
End Sub
any help please?
The problem is that when I insert a different order number, all it does is paste another image on top of the existing image.
I need it to delete the existing picture first before receiving new image and delete the existing picture when Cell (J21) is empty.
Here is the code i am using:
Private Sub Worksheet_Change(ByVal Target As Range)
'paste image from matrix
If Not Intersect(Target, Range("J21", "K22")) Is Nothing Then
If Range("J21").Value <> "" Then
SKU = Range("M23").Value
Workbooks.Open "T:\Production\PROD MOULDING\2 - LINE MANUAL PROJECT\Mouldings Product_Labour Matrix.xls", 0, 1
With Sheets("403").Shapes("" & SKU & "")
.Height = 301
.Width = 101
.Copy
End With
ThisWorkbook.Activate
Sheets("HOME PAGE").Range("Q27").PasteSpecial
With Application
.DisplayAlerts = False
Windows("Mouldings Product_Labour Matrix.xls").Close
.DisplayAlerts = True
End With
Else
'delete shape
End If
End If
End Sub
any help please?
Last edited: