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.
#2 click on “Visual Basic” command under DEVELOPER Tab, or just press “ALT+F11” shortcut.
#3 then the “Visual Basic Editor” window will appear.
#4 click “Insert” ->”Module” to create a new module
#5 paste the below VBA code into the code window. Then clicking “Save” button.
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.
#7 Let’s see the result.