How to automatically change all pictures to "Move and size with cells" in Excel?
When working with images in Excel, you may notice that pictures inserted into your worksheet are set, by default, to the "Move but don’t size with cells" option. This means that if you adjust your cell sizes—such as changing column width or row height—the images remain at their original dimensions, not resizing to fit the new cell layout. For users who need seamless alignment of images with cell adjustments, such as when building dashboards, reports, or visual tracking sheets, this default behavior can be inconvenient and time-consuming to fix manually, especially if your worksheet contains a large number of pictures.
To overcome this challenge, Excel provides a way to change each picture’s property so that it not only moves but also resizes automatically with its cell (“Move and size with cells”). However, changing this setting one image at a time can be laborious. This article presents an efficient approach to automatically update all pictures in a worksheet to “Move and size with cells” by using a straightforward VBA code. This technique is especially useful in scenarios where you often reorganize, filter, or adjust rows and columns containing images, ensuring that your visual elements stay appropriately aligned with your data.
Auto change all pictures to "Move and size with cells" with VBA code
Auto change all pictures to "Move and size with cells" with VBA code
For situations where your worksheet contains multiple images, and you want all of them to adjust consistently with their corresponding cells, you can use the following VBA code to set all picture objects in the active worksheet to “Move and size with cells” instantly. This automated solution eliminates repetitive manual steps, improves workflow efficiency, and reduces the risk of missing images during the process.
Here is a step-by-step guide to applying this VBA solution:
1. Open the worksheet that contains the pictures you want to update so they move and resize together with the cells. Then, launch the Microsoft Visual Basic for Applications editor by pressing Alt + F11 on your keyboard. This shortcut works in most versions of Excel.
Note: If you do not see the Developer tab, you can enable it via Excel Options. In case you are working on a protected or shared workbook, some features might be restricted, so ensure you have the necessary editing permissions.
2. In the Microsoft Visual Basic for Applications window, click Insert > Module to create a new module. Then copy and paste the following VBA code into the code window:
VBA code: change all pictures to "Move and size with cells"
Sub MoveAndSizeWithCells()
Dim xPic As Picture
On Error Resume Next
Application.ScreenUpdating = False
For Each xPic In ActiveSheet.Pictures
xPic.Placement = xlMoveAndSize
Next
Application.ScreenUpdating = True
End Sub Tips:
- Make sure you are working in the correct worksheet before running the macro, as the code will affect all pictures in the currently active sheet.
- If your worksheet contains other objects (such as shapes, charts, or icons), this code specifically targets picture objects and does not modify those.
3. Press F5 or click the Run button in the VBA editor to execute the code. After running, all pictures within your active worksheet will be automatically set to "Move and size with cells". You do not need to select the images one by one—the code processes all at once.
This solution minimizes manual effort and helps maintain consistent formatting, especially when dealing with frequent row or column adjustments. If you notice that some images did not change as expected, double-check that those objects are recognized as pictures by Excel—they should appear as "Picture" in the selection pane, not as other object types.
If you encounter an error during the process, check that you have not accidentally selected a chart sheet, and that images are not locked or grouped. In most cases, running the code as described above will produce the desired result.
To further streamline your workflow, consider saving your workbook before running VBA. If you want to repeat this process regularly, you may assign the macro to a button for one-click access.
As a practical alternative for those uncomfortable with VBA, you can manually change each picture’s property by right-clicking the image, selecting Format Picture, choosing Properties, and then checking “Move and size with cells.” However, this approach is suitable only for worksheets containing a small number of images.
Another related method is using Excel VBA “Selection Pane” to filter and quickly select all pictures before adjusting their properties manually, which can offer more control in complex layouts with various object types.
Related Articles:
- How to center a picture in an Excel cell?
- How to check if a cell contains picture in Excel?
- How to insert image or picture dynamically in cell based on cell value in Excel?
- How to enlarge image when click on it in Excel?
Best Office Productivity Tools
Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time. Click Here to Get The Feature You Need The Most...
Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier
- Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
- Open and create multiple documents in new tabs of the same window, rather than in new windows.
- Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
All Kutools add-ins. One installer
Kutools for Office suite bundles add-ins for Excel, Word, Outlook & PowerPoint plus Office Tab Pro, which is ideal for teams working across Office apps.
- All-in-one suite — Excel, Word, Outlook & PowerPoint add-ins + Office Tab Pro
- One installer, one license — set up in minutes (MSI-ready)
- Works better together — streamlined productivity across Office apps
- 30-day full-featured trial — no registration, no credit card
- Best value — save vs buying individual add-in