delete shape when cell is empty?

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
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,949
Latest member
Dupuhini

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top