Skip to main content

Create a Macro to Delete All Photos in an Excel Spreadsheet

Joshua earned an MBA from USF and he writes mostly about software and technology.

create-a-macro-to-delete-all-photos-in-an-excel-spreadsheet

Deleting photos in a spreadsheet can be a daunting task. This is especially true if you have more than 10 that you need to delete. With a little automation, this task can be completed in seconds. In this tutorial, I record a macro using the go-to function to select all photos. After the photo is selected I delete them and stop recording the task and test the macro.

To start this process, click on the little scroll icon in the bottom left corner of the screen.

create-a-macro-to-delete-all-photos-in-an-excel-spreadsheet

Next, name the macro and select a shortcut to allow you to run the process later. Be mindful that adding these commands with a mac can cause some confusion. Below it appears that I want the macro to run when I press option + command + p but in fact, the command will be control + p. After clicking OK, the macro will begin recording.

create-a-macro-to-delete-all-photos-in-an-excel-spreadsheet

From the home tab, you will see the find and selection option on the top right of the screen by default. Select this option.

create-a-macro-to-delete-all-photos-in-an-excel-spreadsheet

Next, click on go to special.

create-a-macro-to-delete-all-photos-in-an-excel-spreadsheet

Select the objects option. When using this command all objects in a worksheet will be deleted. If you have buttons or other types of inserted objects in your worksheet, they will be deleted as well. Select the OK button.

create-a-macro-to-delete-all-photos-in-an-excel-spreadsheet
create-a-macro-to-delete-all-photos-in-an-excel-spreadsheet

Now select the delete button and click on the stop button in the bottom left-hand corner of the screen.

Scroll to Continue
create-a-macro-to-delete-all-photos-in-an-excel-spreadsheet

When using a Mac, I like to go to the code and check the shortcut keys for the function. To do this, go to the view macros button under the view tab.

create-a-macro-to-delete-all-photos-in-an-excel-spreadsheet

Next, select the macro and click edit.

create-a-macro-to-delete-all-photos-in-an-excel-spreadsheet

Notice that the shortcut is not the original shortcut that I named in the beginning. Every time control + p has been used all objects (including all photos) will be deleted. As long as the worksheet where the macro was created is open, you should be able to use the command while in any workbook.

For those of you who only need the code, you can find it below.

Sub deletepics() ActiveSheet.DrawingObjects.Select Selection.Delete End Sub

create-a-macro-to-delete-all-photos-in-an-excel-spreadsheet

Be sure to save the spreadsheet as a macro-enabled workbook so the macro will work in the future.

create-a-macro-to-delete-all-photos-in-an-excel-spreadsheet

I recorded a short video below showing each of the above tasks with some more context.

This content is accurate and true to the best of the author’s knowledge and is not meant to substitute for formal and individualized advice from a qualified professional.

© 2022 Joshua Crowder

Related Articles