VBA code to delete specific linked picture?

Fabulist

Board Regular
Joined
Jan 28, 2014
Messages
110
I have a table that has two separate rows of data that each function separately and need to have their rows hidden. Thus the table is being split into two, its rows are being hidden accordingly, and the I saw it back together via linking the second part as a picture to the first part, with this code:

Code:
Sub Linked_Picture_Paste()
    Range("C145:K255").Copy
    Range("N22").Select
    Pictures.Paste(Link:=True).Select
    Application.CutCopyMode = False
End Sub

However, when the rows need to be refreshed (via a massive Unhide/Hide macro) the linked picture needs to either be deleted or linked/unlinked.

I have found this macro helps deleting:

Code:
Sub Delete_All_Pictures()
     Dim Pic As Object
     For Each Pic In ActiveSheet.Pictures
     Pic.Delete
     Next Pic
End Sub

But it deletes each and every object/picture in the sheet.

Does anyone know if there is a way to keep the picture permanent and link/unlink it on demand via VBA - or a way to delete that specific linked image so I can rerun the picture link macro each time?
 

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