How to organize images automatically in an Excel file using a macro?

If you add multiple images at once to an Excel file, Excel will try to squeeze them in once cell. It will probably look like the screenshot below.

Instead of manually resizing and relocating these images, you can use the macro below to automatically organize all images in milliseconds.

Sub organizeImages()
     lastTop = 0
     staticHeight = 500

     For Each pic In Worksheets("Sheet1").Pictures
          pic.Top = lastTop
          pic.Height = staticHeight
          lastTop = lastTop + pic.Height + 15
          pic.Left = 0
     Next pic
End Sub

Images resized and relocated automatically:

Leave a Reply