+ Reply to Thread
Results 1 to 3 of 3

Pies and Bubbles together

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    07-29-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    365
    Posts
    255

    Pies and Bubbles together

    Hi all, I have been following the following articles by Andy Pope to combine many pie charts within a bubble chart.

    https://alesandrab.wordpress.com/201...-excel-charts/

    and

    http://www.andypope.info/charts/piedatamarkers.htm

    My sheet has a small piece of VB code that is not running. I cant figure out why?

    MQ.
    Attached Files Attached Files
    Last edited by pickslides; 01-18-2015 at 05:16 PM.
    Be who you are and say what you feel, because those who mind don't matter and those who matter don't mind.

  2. #2
    Forum Guru Kaper's Avatar
    Join Date
    12-14-2013
    Location
    Warsaw, Poland
    MS-Off Ver
    most often: Office 365 in Windows environment
    Posts
    8,678

    Re: Pies and Bubbles together

    Starting debugging:

    There are other references to charts in the code than in the sheet.
    no chtPieMarker at all,
    ChartObjects(1) is a pie chart while shall be chtMarker one

    Correct to:
         Set chtMarker = ActiveSheet.ChartObjects("chtMarker").Chart
          ' reference to chart that pie markers will be applied to
         Set chtMain = ActiveSheet.ChartObjects("chtMain").Chart
    This starts working, but causes an error because you run loop which is too long:
         For Each rngRow In Range("F4:J11").Rows
    while your data extends only to H7
    Use only existing data:
         For Each rngRow In Range(Range("F4"), Range("F4").End(xlToRight).End(xlDown)).Rows
    This runs to the end but visual effect is not perfect, namely aspect ratio is wrong (ovals instead of circles pasted into main chart).
    Either correct manually aspect ratio of whole chtMarker drawning area, or do it in the code.

    Final: at the end of the code you again switch off screen updationg - it has no effect because: 1) is already switched off 2) once the code stops screen updating is switched on.
    intPoint variable is unused

    So the code at this stage (code is never final - probably still more debugging needed :-P ) could be:

    Sub PieMarkers()
         Dim chtMarker As Chart
         Dim chtMain As Chart
         Dim rngRow As Range
         Dim lngPointIndex As Long
          
         Application.ScreenUpdating = False
         'make sure pie is drawn on square drawning area
         With ActiveSheet.Shapes("chtMarker")
           .LockAspectRatio = msoFalse
           .ScaleWidth .Height / .Width, msoFalse, msoScaleFromTopLeft
           .LockAspectRatio = msoTrue
         End With
         ' reference to pie chart
         Set chtMarker = ActiveSheet.ChartObjects("chtMarker").Chart
          ' reference to chart that pie markers will be applied to
         Set chtMain = ActiveSheet.ChartObjects("chtMain").Chart
          ' pie chart data which will be processed by rows
         For Each rngRow In Range(Range("F4"), Range("F4").End(xlToRight).End(xlDown)).Rows
              ' assign new values to pie chart
             chtMarker.SeriesCollection(1).Values = rngRow
              ' copy pie
             chtMarker.Parent.CopyPicture xlScreen, xlPicture
              ' paste to appropriate data point
             lngPointIndex = lngPointIndex + 1
             chtMain.SeriesCollection(1).Points(lngPointIndex).Paste
         Next
          ' release objects
         Set chtMarker = Nothing
         Set chtMain = Nothing
         Application.ScreenUpdating = True
    End Sub
    Last edited by Kaper; 01-14-2015 at 03:22 AM. Reason: intPoint variable not used in code
    Best Regards,

    Kaper

  3. #3
    Forum Contributor
    Join Date
    07-29-2009
    Location
    Melbourne, Australia
    MS-Off Ver
    365
    Posts
    255

    Re: Pies and Bubbles together

    Hi Kaper, thanks for reply, I have used your suggestion and you are right there is more debugging to be done.

    Will start again from scratch.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Bubbles Plots with Pies as Bubbles
    By Frotty in forum Excel Charting & Pivots
    Replies: 4
    Last Post: 06-23-2012, 05:44 AM
  2. Cant get my pies to be the same size.
    By dshilan in forum Excel General
    Replies: 2
    Last Post: 06-29-2010, 09:31 AM
  3. Pies of Pie chart
    By grant862 in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 05-13-2008, 03:41 AM
  4. [SOLVED] How do a put two pies (series) in one chart
    By tartanspice in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 01-23-2006, 11:35 AM
  5. [SOLVED] Multiple Pies in One Chart?
    By EPratt in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 08-02-2005, 05:05 PM

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