
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: Fluff, Ineke Smit
Guest(s) 11
Currently Browsing this Page:
1 Guest(s)
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 880
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 237
Jessica Stewart: 219
A.Maurizio: 213
Aye Mu: 201
Hans Hallebeek: 186
Newest Members:
Kate Dyka
Kwaje Alfred Mogga
thong nguyen
Appiagyei Kofi Frimpong
Hilary Burchfield
Richie Wright
Adel Kock
Barbara Murray
Doug Milne
Siobhan Stringer
Forum Stats:
Groups: 3
Forums: 24
Topics: 6546
Posts: 28658
Member Stats:
Guest Posters: 49
Members: 32832
Moderators: 2
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: Velouria, Riny van Eekelen
© Simple:Press —
