+ Reply to Thread
Results 1 to 9 of 9

Any way to center a graphic in a particular cell?

  1. #1
    Registered User
    Join Date
    04-29-2005
    Posts
    15

    Any way to center a graphic in a particular cell?

    I have a small graphic that I need into insert to every applicable cell, in a certain column. Is there any sort of way that excel can be formatted to have this graphic be centered in each cell? It is quite tough to keep everything centered by hand. Thanks!

  2. #2
    Registered User
    Join Date
    04-29-2005
    Posts
    15
    Yay, pity bump.

  3. #3
    Debra Dalgleish
    Guest

    Re: Any way to center a graphic in a particular cell?

    Graphics float over cells, so they aren't affected by cell formatting.
    You could use programming to centre the graphics, but there's no
    built-in command that will centre them.

    metalsped wrote:
    > I have a small graphic that I need into insert to every applicable cell,
    > in a certain column. Is there any sort of way that excel can be
    > formatted to have this graphic be centered in each cell? It is quite
    > tough to keep everything centered by hand. Thanks!
    >
    >



    --
    Debra Dalgleish
    Contextures
    http://www.contextures.com/tiptech.html


  4. #4
    Registered User
    Join Date
    04-29-2005
    Posts
    15
    Well this is for work, so it needs to be professional looking. Provided I dont have to write an encyclopedia worth of commands for every box, I would love to try out the program (if you know it). Thanks

    Quote Originally Posted by Debra Dalgleish
    Graphics float over cells, so they aren't affected by cell formatting.
    You could use programming to centre the graphics, but there's no
    built-in command that will centre them.

    metalsped wrote:
    > I have a small graphic that I need into insert to every applicable cell,
    > in a certain column. Is there any sort of way that excel can be
    > formatted to have this graphic be centered in each cell? It is quite
    > tough to keep everything centered by hand. Thanks!
    >
    >



    --
    Debra Dalgleish
    Contextures
    http://www.contextures.com/tiptech.html

  5. #5
    Debra Dalgleish
    Guest

    Re: Any way to center a graphic in a particular cell?

    Assuming the graphics are narrower than the columns, you could use code
    similar to the following:

    '====================
    Sub CentreGraphics()
    Dim shp As Shape
    For Each shp In ActiveSheet.Shapes
    shp.Left = shp.TopLeftCell.Left _
    + (shp.TopLeftCell.Width - shp.Width) / 2
    Next shp
    End Sub
    '=====================

    metalsped wrote:
    > Well this is for work, so it needs to be professional looking. Provided
    > I dont have to write an encyclopedia worth of commands for every box, I
    > would love to try out the program (if you know it). Thanks
    >
    > Debra Dalgleish Wrote:
    >
    >>Graphics float over cells, so they aren't affected by cell formatting.
    >>You could use programming to centre the graphics, but there's no
    >>built-in command that will centre them.
    >>
    >>metalsped wrote:
    >>
    >>>I have a small graphic that I need into insert to every applicable

    >>
    >>cell,
    >>
    >>>in a certain column. Is there any sort of way that excel can be
    >>>formatted to have this graphic be centered in each cell? It is quite
    >>>tough to keep everything centered by hand. Thanks!
    >>>
    >>>

    >>
    >>
    >>--
    >>Debra Dalgleish
    >>Contextures
    >>http://www.contextures.com/tiptech.html

    >
    >
    >



    --
    Debra Dalgleish
    Contextures
    http://www.contextures.com/tiptech.html


  6. #6
    Registered User
    Join Date
    04-29-2005
    Posts
    15
    I feel quite silly asking, but where exactly in my excel sheet do I put code like that? Sorry for all the questions.

  7. #7
    Debra Dalgleish
    Guest

    Re: Any way to center a graphic in a particular cell?

    Store the code in a regular code module, as described here:

    http://www.contextures.com/xlvba01.html

    To run the code, you can choose Tools>Macro>Macros
    Select the CentreGraphics macro in the list, then click the Run button.

    metalsped wrote:
    > I feel quite silly asking, but where exactly in my excel sheet do I put
    > code like that? Sorry for all the questions.
    >
    >



    --
    Debra Dalgleish
    Contextures
    http://www.contextures.com/tiptech.html


  8. #8
    Registered User
    Join Date
    04-29-2005
    Posts
    15
    I'm halfway there. Thank you thus far Debra. It appears with that coding, that it is centered vertically. Is there any way to have it centered horizontally as well?

  9. #9
    Ken Johnson
    Guest

    Re: Any way to center a graphic in a particular cell?

    Hi metalsped,

    try...

    Sub CentreGraphics()
    Dim shp As Shape
    For Each shp In ActiveSheet.Shapes
    shp.Left = shp.TopLeftCell.Left _
    + (shp.TopLeftCell.Width - shp.Width) / 2
    shp.Top = shp.TopLeftCell.Top _
    + (shp.TopLeftCell.Height - shp.Height) / 2
    Next shp
    End Sub

    Ken Johnson


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1