+ Reply to Thread
Results 1 to 2 of 2

Macro to create dynamic pie chart

  1. #1
    Registered User
    Join Date
    01-03-2014
    Location
    London, England
    MS-Off Ver
    Excel 2003
    Posts
    1

    Macro to create dynamic pie chart

    Hi everyone

    I would really appreciate any help I can get with this.
    Basically what I am trying to do is create a macro that will produce a pie chart that will update everytime new data is entered into the next row.
    I have attached an example of my data

    I can record a macro and create a pie chart but i would like the macro to show the most recent data every time it is run and obviously when you record a macro Excel fixes the data.

    This is how far i have got, bu the more i fiddle with this the more confused i become

    Sub test()

    Dim ShName As String
    With ActiveSheet
    ShName = .Name
    End With

    Charts.Add
    With ActiveChart
    .ChartType = xlPie
    .SetSourceData Source:=Range("K" & .Rows.Count).End(xlUp).Row
    End With
    .SeriesCollection(1).Name = "=""Sentiment: Twitter - BU"""
    .SeriesCollection(1).XValues = "='INPUT'!$K$5:$M$5"
    .SetElement (msoElementDataLabelBestFit)
    .Location Where:=xlLocationAsObject, Name:=ShName

    End With

    End Sub


    I know the .SetSourceData line is wrong but i'm not sure how to fix this?
    If you have an entirely different code that would be welcome too.
    Attached Files Attached Files

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Macro to create dynamic pie chart

    You might be better using a dynamic named range approach to achieve your goal.

    Have a look at

    http://office.microsoft.com/en-gb/ex...001109801.aspx
    Martin

+ 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. How to create a dynamic chart off dynamic data
    By jananas in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 08-07-2013, 10:48 AM
  2. Can I create a dynamic chart with a dynamic number of series?
    By SG2 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 06-24-2011, 08:44 AM
  3. macro to create pie chart based on dynamic ranges
    By jarssonn in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-04-2010, 11:00 AM
  4. How do I create a dynamic chart
    By Nick Krill in forum Excel Charting & Pivots
    Replies: 5
    Last Post: 01-21-2006, 04:25 PM
  5. Create a dynamic chart with code
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-02-2005, 01:05 PM

Tags for this Thread

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