Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Jan 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Center Pie Chart in Excel Cell

    Is there an efficient way to center a pie chart in an Excel cell? For example, I need to create a page of pie charts, each with different source data. So I duplicate a newly created, formatted pie chart, using CTRL D. Then I have to move it, and as anyone who has done this, knows, you cann use arrows to move the chart, but have to highlight the chart and use the mouse to move it.

    Thanks in advance for any help!

  2. #2
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,224
    Thanks
    14
    Thanked 340 Times in 333 Posts
    Could you elaborate on what you want?

    For example, What do you want to center it based on? Do you want the chart to completely fill the cell, the top left corner is in? Keep the size it is and center it in that cell? What happens if the cell is not big enough?

    Do you want to have a macro based on the selected chart object or just work on all the chartobjects in the worksheet?

    Steve

  3. #3
    5 Star Lounger Maudibe's Avatar
    Join Date
    Aug 2010
    Location
    Pa, USA
    Posts
    1,193
    Thanks
    43
    Thanked 226 Times in 210 Posts
    cbertx,

    Not sure if this is what you are looking for but consider the following code.

    Setup:
    Insert code in a standard module. On the developer tab, click Macros> Make sure that MoveChart is highlighted> Options...> enter m for the crtl shortcut> OK.

    Running the code:
    Select the cell where you want the left upper corner of the chart to be then click Ctrl-m. The chart will be duplicated and placed in the position you specified. Repeat the process to paste as many charts as you wish.

    HTH,
    Maud

    In the following example, click cell C1 the press ctrl-m

    movechart1.png movechart2.png

    Code:
    Public Sub MoveChart()
    ActiveSheet.Shapes("Chart 2").Copy  'CHANGE NAME TO NAME OF CHART
    ActiveSheet.Paste
    End Sub
    Attached Files Attached Files
    Last edited by Maudibe; 2014-01-24 at 19:32. Reason: add file

  4. #4
    5 Star Lounger Maudibe's Avatar
    Join Date
    Aug 2010
    Location
    Pa, USA
    Posts
    1,193
    Thanks
    43
    Thanked 226 Times in 210 Posts
    Again, if this is what you are looking for, here is a little trick that will allow you to copy the charts even faster. Assuming the shortcut keys are still set, when you press ctrl-m, you will enter a "chart mode" indicated by the cursor changing to an I-beam. Any cell you that you click on while in this mode, the copied chart will be placed. To exit the "chart mode", press ctrl-m again and the cursor will return to the default cursor. Toggle back and forth using the shortcut keys.

    Standard module:
    Code:
    Public Mode As Integer
    
    Public Sub MoveChart()
    If Mode = 1 Then
        Application.Cursor = xlDefault
        Mode = 0
    Else
        Application.Cursor = xlIBeam
        Mode = 1
    End If
    End Sub
    Worksheet module:
    Code:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Mode = 1 Then
        ActiveSheet.Shapes("Chart 2").Copy  'CHANGE NAME OF SOURCE CHART IF NEEDED
        ActiveSheet.Paste
    End If
    End Sub
    Attached Files Attached Files

Tags for this Thread

Posting Permissions

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