lpking2005
Board Regular
- Joined
- Mar 21, 2011
- Messages
- 140
i have run into a problem,
i have some code which uses a string of numbers on a sheet and then opens another workbook and selects an image which has been renamed with this number.
it then copy/pastes this image back into my original workbook.
im having trouble telling it to delete the shape/picture if cell (J21) is blank.
any help will be much appreciated. thanks.
this is my code:
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 "H:\Digital Line Manuals\Database Maintenance\Master Mouldings Product_Labour Matrix.xls", 0, 1
With Sheets("403").Shapes("" & SKU & "")
.Height = 311
.Width = 111
.Copy
End With
ThisWorkbook.Activate
Sheets("HOME PAGE").Range("Q27").PasteSpecial
Selection.Name = "34002932"
Sheets("HOME PAGE").Shapes("34002932").Delete
With Application
.DisplayAlerts = False
Windows("Master Mouldings Product_Labour Matrix.xls").Close
.DisplayAlerts = True
End With
Else
'delete shape
End If
ElseIf Not Intersect(Target, Range("C1")) Is Nothing Then
If Range("C1").Value = "*" Then
ActiveSheet.CommandButton8.Visible = True
Application.EnableEvents = False
Range("C1").Value = ""
Application.EnableEvents = True
Else
ActiveSheet.CommandButton8.Visible = False
Application.EnableEvents = False
Range("C1").Value = ""
Application.EnableEvents = True
End If
End If
End Sub
i have some code which uses a string of numbers on a sheet and then opens another workbook and selects an image which has been renamed with this number.
it then copy/pastes this image back into my original workbook.
im having trouble telling it to delete the shape/picture if cell (J21) is blank.
any help will be much appreciated. thanks.
this is my code:
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 "H:\Digital Line Manuals\Database Maintenance\Master Mouldings Product_Labour Matrix.xls", 0, 1
With Sheets("403").Shapes("" & SKU & "")
.Height = 311
.Width = 111
.Copy
End With
ThisWorkbook.Activate
Sheets("HOME PAGE").Range("Q27").PasteSpecial
Selection.Name = "34002932"
Sheets("HOME PAGE").Shapes("34002932").Delete
With Application
.DisplayAlerts = False
Windows("Master Mouldings Product_Labour Matrix.xls").Close
.DisplayAlerts = True
End With
Else
'delete shape
End If
ElseIf Not Intersect(Target, Range("C1")) Is Nothing Then
If Range("C1").Value = "*" Then
ActiveSheet.CommandButton8.Visible = True
Application.EnableEvents = False
Range("C1").Value = ""
Application.EnableEvents = True
Else
ActiveSheet.CommandButton8.Visible = False
Application.EnableEvents = False
Range("C1").Value = ""
Application.EnableEvents = True
End If
End If
End Sub