Selecting shapes

garrett1483

New Member
Joined
Sep 5, 2011
Messages
36
Hello - i have a worksheet and in column A i have a bunch of photos (.jpg) and let's say in column B i have some more photos. A lot of times i only need to select certain photos in Column A or select specific photos in Column A and B versus selecting all shapes/objects. Is there a script i can run to make this happen?
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
If you know the name of a specific photo, like say Picture 1, then
Activesheet.Shapes("Picture 1").Select
 
Upvote 0
Is there any way to do it with out knowing the specific name of each file? There are times when i have to select multiple photos, like up to 50 photos. Is there a way to setup the code like "activesheet.shapes("a3:a5).select ? - i know nothing about vba code by the way, just what i learn on this forum as i go.
 
Upvote 0
Is there any way to do it with out knowing the specific name of each file? There are times when i have to select multiple photos, like up to 50 photos. Is there a way to setup the code like "activesheet.shapes("a3:a5).select ? - i know nothing about vba code by the way, just what i learn on this forum as i go.

Here's one way, which depends on you knowing the indices of the images. Say your 50 pictures have index numbers from 1 to 50:
Code:
Sub SelectPictures()
For i = 1 To 50
    If InStr(ActiveSheet.Shapes(i).Name, "Picture") Then
        ActiveSheet.Shapes(i).Select Replace:=False
    End If
Next i
End Sub
This will select all 50. The If -Then part ensures that if there are other shapes with an index number between 1 & 50, they will not be selected. To select all pictures on the sheet you could use:
For i = 1 to Activesheet.Shapes.Count
 
Upvote 0
Hi Joe. I am working on a similar project, but I don't understand how you inserted a picture into a cell. Whenever I insert a picture, it places the picture on top of the document. I did research and find an add-on to Excel for $20 I think that would do this. I was given this code to select pictures in a file and delete them, but the code isn't working. I tried adding activesheet to the beginning and it still showed the error. Any help would be appreciated.

Shapes.SelectAll
Selection.Delete
 
Upvote 0
Hi Joe. I am working on a similar project, but I don't understand how you inserted a picture into a cell. Whenever I insert a picture, it places the picture on top of the document. I did research and find an add-on to Excel for $20 I think that would do this. I was given this code to select pictures in a file and delete them, but the code isn't working. I tried adding activesheet to the beginning and it still showed the error. Any help would be appreciated.

Shapes.SelectAll
Selection.Delete
The pictures the OP referenced are not inserted in cells to the best of my knowledge. Activesheet.Shapes.SelectAll
will select all shapes (including but not limited to pictures) on the active sheet.
 
Upvote 0

Forum statistics

Threads
1,202,913
Messages
6,052,530
Members
444,589
Latest member
Ben AFF

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