Tip: Other languages are Google-Translated. You can visit the English version of this link.
Log in


How to resize pictures to fit cells in Excel?

Normally inserted pictures floats over cells, and most of time one pictures covers a lot of cells. If a worksheet has a large number of pictures, you may want to put each picture into a single cell. But how to deal with it? Actually, there are several tricky ways to help us resize pictures to fit cells' size quickly.

Resize a selected picture to fit a single cell with VB Macro

Resize inserted pictures to fit cells with Kutools for Excel

Excel Productivity Tools

Office Tab: Bring powerful tabs to Office (include Excel), just like Chrome, Safari, Firefox and Internet Explorer. Save you half the time, and reduce thousands of mouse clicks for you. 30-day Unlimited Free Trial

Kutools for Excel: Save 70% of your time and solve 80% Excel problems for you. 300+ advanced features designed for 1500+ work scenario, make Excel much easy and increase productivity immediately. 60-day Unlimited Free Trial

arrow blue right bubble Resize a selected picture to fit a single cell with VB Macro

We can apply VB macros to resize a selected picture to fit a single cell, but not manually resize a picture's width and height. You can do it with following steps:

Step 1: Insert the pictures in to a worksheet, and select a picture that you will resize it to fit a single cell.


Step 2: Hold down the ALT + F11 keys, and it opens the Microsoft Visual Basic for Applications window.

Step 3: Click Insert > Module, and paste the following macro in the Module Window.

VBA: Resize a selected picture to fit a cell.

Public Sub FitPic()
Dim PicWtoHRatio As Single
Dim CellWtoHRatio As Single
With Selection
PicWtoHRatio = .Width / .Height
End With
With Selection.TopLeftCell
CellWtoHRatio = .Width / .RowHeight
End With
Select Case PicWtoHRatio / CellWtoHRatio
Case Is > 1
With Selection
.Width = .TopLeftCell.Width
.Height = .Width / PicWtoHRatio
End With
Case Else
With Selection
.Height = .TopLeftCell.RowHeight
.Width = .Height * PicWtoHRatio
End With
End Select
With Selection
.Top = .TopLeftCell.Top
.Left = .TopLeftCell.Left
End With
Exit Sub
MsgBox "Select a picture before running this macro."
End Sub

Step 4: Press the F5 key to run this macro.

Step 5: Repeat the steps above to resize other pictures to fit single cell.

Now all inserted pictures are resized and fits into cells. See the following screenshot:


Note: You can resize only one picture one time. If you select more than one picture one time, a warning dialog box will pop up.

arrow blue right bubble Resize inserted pictures to fit cells with Kutools for Excel

If you have Kutools for Excel installed, you can apply its Import Pictures tool to resize all pictures to fit cells or with fixed height during inserting pictures.

Kutools for Excel includes more than 300 handy Excel tools. Free to try with no limitation in 30 days. Get it Now.

Step 1: Select the range cells you want to insert pictures and click the Enterprise >Import/Export > Import Pictures. See the following screenshot:


Step 2: In the Import Pictures dialog box, select the inserting order in the drop-down list, and click Add button to add pictures you need from file or folder, then click Size button. See screenshot:


Step 3: Check Matching cell size option. Then click Ok > Import to close dialogs. See screenshot:


Now you can see the pictures are inserted to fit the cells.


Note: You also can specify the cell height and width in step 3 to resize the pictures.

If you want to know more about this Import Picture feature, please visit here.

Related Article:

How to resize multiple cells to fit pictures above them quickly in Excel?

Excel Productivity Tools

Ribbon of Excel (with Kutools for Excel installed)

300+ Advanced Features Increase Your Productivity by 70%, and Help You To Stand Out From Crowd

Would you like to complete your daily work quickly and perfectly? Kutools for Excel brings 300+ cool and powerful advanced features (Combine workbooks, sum by color, split cell contents, convert date, and so on...) for you.

  • Designed for 1500+ work scenarios, helps you solve 80% Excel problems.
  • Save a lot of work time, leave much time for you to love and care the family and enjoy a comfortable life now.
  • Reduce thousands of keyboard and mouse clicks every day, relieve your tired eyes and hands.
  • Become an Excel expert in 3 minutes. No longer need to remember any painful formulas and VBA codes.
  • 60-day unlimited free trial. 60-day money back guarantee. Free upgrade and support for 2 years. Buy once, use forever.
  • Being used by 110,000 elites and 300+ well-known companies.

Office Tab Brings Efficient And Handy Tabs to Office (include Excel), Just Like Chrome, Firefox, And New IE

  • Increases your productivity by 50% when viewing and editing multiple documents.
  • Reduce hundreds of mouse clicks for you every day, say goodbye to mouse hand.
  • Open and create documents in new tabs of same window, rather than in new windows.
  • One second to switch between dozens of open documents!
Say something here...
symbols left.
You are guest ( Sign Up? )
or post as a guest, but your post won't be published automatically.
Loading comment... The comment will be refreshed after 00:00.
  • To post as a guest, your comment is unpublished.
    Syed Waqas Gillani · 2 months ago
    perfact solution. But i want that function to work with command button. i need to make a command button to insert and auto resize to cell size. please help.
  • To post as a guest, your comment is unpublished.
    Shripad Lale · 2 years ago
    Brilliant! Works great! Just what I was looking for! Thank you!
  • To post as a guest, your comment is unpublished.
    claus · 2 years ago
    it works if the cells are not merged. unfortunately, I merged some cells and it fits only in the upper left cell which makes the photo very tiny.
  • To post as a guest, your comment is unpublished.
    Harry · 3 years ago
    Hi, I really love this macro that makes images fit cells, it really helped me with some work stuff. But does anyone know how to write this code for applescript? I have to use macs and the apple version of excel, Numbers, only uses applescript.
    Many thanks,
  • To post as a guest, your comment is unpublished.
    Carol · 3 years ago
    Thanks it did work but I have about 500 pictures so I don't want to do them one at a time - how do I do them all at the same time please?