Center an Image in an Excel Cell

This post will guide you how to center an image file in an excel cell. And how do I center to align a graphic in an excel cell. How to align a picture within a cell. How to align a picture to the center of a cell with VBA code in excel.

Center an Image in an Excel Cell


To quickly center an image in an excel cell, you can create an excel VBA macro to achieve the result. Just do the following steps:

#1 import one picture into the current worksheet.

center iamge11

 

#2 click on “Visual Basic” command under DEVELOPER Tab, or just press “ALT+F11” shortcut.

Get the position of the nth using excel vba1

#3 then the “Visual Basic Editor” window will appear.

#4 click “Insert” ->”Module” to create a new module

convert column number to letter3

#5 paste the below VBA code into the code window. Then clicking “Save” button.

center iamge1

Sub CenterImages()
    With ActiveSheet.Shapes("Picture 1")
        .Top = Range("B1").Top + (Range("B1").Height - .Height) / 2
        .Left = Range("B1").Left + (Range("B1").Width - .Width) / 2
    End With
End Sub

Note: You can change the picture name and cell reference as you need in your worksheet.

#6 back to the current worksheet, then run the above excel macro. Click Run button.

center iamge2

#7 Let’s see the result.

center iamge3

Comments

So empty here ... leave a comment!

Leave a Reply

Your email address will not be published. Required fields are marked *

Sidebar