How to center a picture in an Excel cell?
This article will show you a method of moving pictures to the center of cells in an Excel worksheet as below screenshot shown.
Move picture to center of cell with VBA code
Move picture to center of cell with VBA code.
Please do as follows to move pictures to the center of cells in a worksheet in Excel.
1. Open the worksheet contains the pictures you need to center in cells, then press the Alt + F11 keys to open the Microsoft Visual Basic for Applications window.
2. In the Microsoft Visual Basic for Applications window, please click Insert > Module. Then copy and paste VBA code into the Code window.
VBA code: Move pictures to center of cells in worksheet
Sub CenterPictures()
With ActiveSheet.Shapes("Picture 2")
.Top = Range("A1").Top + (Range("A1").Height - .Height) / 2
.Left = Range("A1").Left + (Range("A1").Width - .Width) / 2
End With
With ActiveSheet.Shapes("Picture 4")
.Top = Range("A2").Top + (Range("A2").Height - .Height) / 2
.Left = Range("A2").Left + (Range("A2").Width - .Width) / 2
End With
With ActiveSheet.Shapes("Picture 6")
.Top = Range("A3").Top + (Range("A3").Height - .Height) / 2
.Left = Range("A3").Left + (Range("A3").Width - .Width) / 2
End With
End Sub
Notes:
With ActiveSheet.Shapes("Picture name")
.Top = Range("Cell Address").Top + (Range("Cell Address").Height - .Height) / 2
.Left = Range("Cell Address").Left + (Range("Cell Address").Width - .Width) / 2
End With
3. Press the F5 key to run the code.
Then all specified pictures will be moved to the center of certain cells immediately as below screenshot shown.
Related Articles:
- How to automatically change all pictures to move and size with cells in Excel?
- 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
Supports Office/Excel 2007-2021 and 365 | Available in 44 Languages | Easy to Uninstall Completely
Kutools for Excel Boasts Over 300 Features, Ensuring That What You Need Is Just A Click Away...
Supercharge Your Excel Skills: Experience Efficiency Like Never Before with Kutools for Excel (Full-Featured 30-Day Free Trial)
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! (Full-Featured 30-Day Free Trial)





