Milena Stevanov
New Member
Members
Forum Posts: 2
Member Since:
May 5, 2018
May 5, 2018
Offline
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
Offline
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
Offline
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online:
Guest(s) 9
Currently Browsing this Page:
1 Guest(s)
1 Guest(s)
Top Posters:
Catalin Bombea: 1939
SunnyKow: 1432
Anders Sehlstedt: 929
Purfleet: 415
Hans Hallebeek: 354
Frans Visser: 349
David_Ng: 312
lea cohen: 248
Jessica Stewart: 219
A.Maurizio: 216
Newest Members:
EXerOrqW PRqmMlMeyNd
EZKeMKxZBN iWcVrtJiiOmoVRc
Pamela Malthouse
Lila Huron-Albinger
Harry Maxwell
Jie Liu
Susan Lanham
Dhanushka Rathnayake
Rena Towles
Wim Verhaege
Forum Stats:
Groups: 3
Forums: 25
Topics: 7093
Posts: 31099
Member Stats:
Guest Posters: 49
Members: 34528
Moderators: 2
Admins: 3
Administrators: Mynda Treacy, Philip Treacy, Jessica
Moderators: Velouria, Riny van Eekelen
© Simple:Press —