Question:

Center Image on Excel Cell?

by Guest59722  |  earlier

0 LIKES UnLike

In Excel 2007, can you "center middle" an insert image in a cell (left right top bottom)????

 Tags:

   Report

1 ANSWERS


  1. The answer to your question is no and yes.  

    No, you can’t set the alignment of an image in a cell the way you do for normal contents because images are not contained in cells, they exist at a position and with a size in the worksheet.

    Yes, you can accomplish what you want if know or can learn how to use VBA macros because both cells and images exist at a position and with a size in the worksheet.  So you can set the position and size of an image based on the position and size of a cell (or range).

    The examples below are for pictures but would be similar for shapes or other inserted images.  Familiarity with VBA macros is assumed, you may contact me via Answers email if you need more help in that area    



    To exactly cover cell E5 with a picture

    Pictures(1).Top = Cells(5, 5).Top

    Pictures(1).Left = Cells(5, 5).Left

    Pictures(1).Height = Cells(5, 5).Height

    Pictures(1).Width =Cells(5, 5).Width

    To exactly cover a range

    Pictures(1).Top =  Range("E5:H11").Top

    Pictures(1).Left =  Range("E5:H11").Left

    Pictures(1).Height = Range("E5:H11").Height

    Pictures(1).Width =  Range("E5:H11").Width

    To partially cover a cell (centred) – Bottom or top centred text would appear below or above the picture in the cell.

    Pictures(1).Top = Cells(5, 5).Top + (Cells(5, 5).Height /10)

    Pictures(1).Left = Cells(5, 5).Left  + (Cells(5, 5).Width /10)

    Pictures(1).Height = Cells(5, 5).Height - (Cells(5, 5).Height /5)

    Pictures(1).Width =Cells(5, 5).Width - (Cells(5, 5).Width /5)

    Place the code in either the Worksheet_Activate or Worksheet_SelectionChange subroutine (or both) depending on whether worksheet changes are expected.

    Be aware of what inserting or deleting cells, columns, or rows can do when either the cells are not all the same size or they contain values.

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.