
Milena Stevanov
New Member
Members

Forum Posts: 2
Member Since:
May 5, 2018
May 5, 2018

I have a macro that imports data from a selected file. The data includes some images. The problem I am having is if i have data and images already in my document, and I go to import new data, the images do not delete and simply get pasted on top of each other. I wrote code to select the cells and clear them, but it doesn't clear the images.
I think the solution is to put some code at the beginning that can select the images in the cell range and delete them, before the new data is imported.
I came across a solution that Selects all images in the worksheet and deletes them, But I have other images that I need to keep.
Is is possible to tell it to select all images in a specific range of cells?

SunnyKow
Puchong, Malaysia
VIP
Members

Trusted Members

Trusted Members

Forum Posts: 1432
Member Since:
June 25, 2016
June 25, 2016

Hi Milena
Welcome to the forum.
Just select the required range and then run the macro below.
Sub DeletePictures()
Dim Sh As Shape
For Each Sh In ActiveSheet.Shapes
If Not Application.Intersect(Sh.TopLeftCell, Range(Selection.Address)) Is Nothing Then
Sh.Delete
End If
Next Sh
End Sub
Hope this helps.
Sunny

Answers Post

SunnyKow
Puchong, Malaysia
VIP
Members

Trusted Members

Trusted Members

Forum Posts: 1432
Member Since:
June 25, 2016
June 25, 2016

Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Rocco Pinneri, Alexandra Radu, AndyC
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 871
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Raj Mattoo
Mark Luke
terimeri dooriyan
Jack Aston
AndyC
Denise Lloyd
michael serna
mashal sana
Tiffany Kang
Leah Gillmore
Forum Stats:
Groups: 3
Forums: 24
Topics: 6219
Posts: 27276
Member Stats:
Guest Posters: 49
Members: 31903
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —
