Skip to main content

Create a Macro to Delete All Photos in an Excel Spreadsheet

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

Deleting images in a spreadsheet can be a daunting task. This is especially true if you have more than 10 images on a sheet that must be deleted. 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 images. After all images in a spreadsheet are selected, I delete them and stop recording. I then test to make sure the macro works.

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

Clicking the scroll at the bottom of the Excel window will allow you to start recording a macro.

Clicking the scroll at the bottom of the Excel window will allow you to start recording a macro.

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 select" option on the top right of the Excel ribbon by default. Select this option.

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

Next, click on the "go to special" option.

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

The images below will be deleted in my Example.

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

Since the previous process selects all of the images in a spreadsheet, all that is left to do is click delete to remove the images. To stop recording the macro, click on the stop button at the bottom of the screen.

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 key that operates 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 this 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

Here the recorded macro is shown in the module where it is saved.

Here the recorded macro is shown in the module where it is saved.

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

The only way to operate Excel workbooks with macros is to save the files as macro-enabled workbooks.

The only way to operate Excel workbooks with macros is to save the files as macro-enabled workbooks.

I recorded a short video below showing each of the above tasks with some more context in case you are having issues.

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