+ Reply to Thread
Results 1 to 11 of 11

VBA create chart with specific colors

  1. #1
    Registered User
    Join Date
    05-19-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    18

    VBA create chart with specific colors

    Hi @all,

    I've one excelsheet with 2 tables. Table 1 is called "Auswertung" and should only showing the chart. Table 2 is called "Tabelle2" and includes the Range("A1:B23"). In A there are several categories and B is counting how often the categories are found in another excelsheet . The following macro is creating one chart for me:

    Please Login or Register  to view this content.
    The columns in this charts have the same color, but I want different colors if the value of "B" is bigger than 2. So how would it look then?

    Thx@all
    Last edited by lucascaletta; 07-22-2014 at 08:16 AM.

  2. #2
    Registered User
    Join Date
    02-06-2013
    Location
    Ezinge, The Netherlands
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    65

    Re: VBA create chart with specific colors

    Hi lucascaletta,

    I think this can be something usefull?

    Please Login or Register  to view this content.
    Just paste the code before your 'End Sub'

  3. #3
    Registered User
    Join Date
    05-19-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: VBA create chart with specific colors

    Hi "thelongpants" ,

    I've get one runtime error, if I would paste ur code before my "end sub":

    Runtime Error '1004' (invalid parameters) with the line: a = ch.Chart.SeriesCollection(2).Values

    Any ideas?


  4. #4
    Registered User
    Join Date
    02-06-2013
    Location
    Ezinge, The Netherlands
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    65

    Re: VBA create chart with specific colors

    Hi,

    Hm... can you send me your file? Probably something with references or identification of the variables...

  5. #5
    Registered User
    Join Date
    05-19-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: VBA create chart with specific colors

    Sure, pls take a look to the attached file. I've insert 2 buttons
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    02-06-2013
    Location
    Ezinge, The Netherlands
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    65

    Re: VBA create chart with specific colors

    Hi Lucascaletta,

    Please Login or Register  to view this content.
    into:

    Please Login or Register  to view this content.
    It seems that your graph only has 1 collection of data (in my testcase I just created a default graph).

    Problem solved?

    Kind regards,

    Tom

  7. #7
    Registered User
    Join Date
    05-19-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: VBA create chart with specific colors

    hi,

    unfortunately not, you can test it with my attached file in the upper comment.

  8. #8
    Registered User
    Join Date
    05-19-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: VBA create chart with specific colors

    I've change all SeriesCollection(2) to SeriesCollection(1), no it works. Can u explain this further, pls?

  9. #9
    Registered User
    Join Date
    02-06-2013
    Location
    Ezinge, The Netherlands
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    65

    Re: VBA create chart with specific colors

    Good job! :-)
    Sorry, I was not really focussed.

    Explanation:
    The way a graph is illustrated / build by Excel is depending on the graph type. Some graphs use multiple collections (series) of points to visualize a line in the graph. Others only use 1 collection, like yours.

    More (technical) info can be found on the web, like here: http://www.java2s.com/Code/VBA-Excel...tingCharts.htm

  10. #10
    Registered User
    Join Date
    05-19-2014
    Location
    Germany
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: VBA create chart with specific colors

    Thanks "thelongpants" for ur support

    Hopefully, we'll read us in another thread :P

  11. #11
    Registered User
    Join Date
    02-06-2013
    Location
    Ezinge, The Netherlands
    MS-Off Ver
    Excel 2003, 2007, 2010, 2013
    Posts
    65

    Re: VBA create chart with specific colors

    Hi Lucascaletta,

    No problem, my pleasure :-)

    We'll see,... I started my experience in VBA with a lot of questions as well, now started returning answers :-)
    Please mark this thread as 'solved' and add some reputation to my comments if you like!

+ 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 specific dual axis chart
    By rgold in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 04-16-2009, 10:51 AM
  2. [SOLVED] create chart /table excel-save, close & reopen colors change? Why
    By Anne in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 07-04-2006, 04:20 PM
  3. HOW TO CREATE A BUBBLE CHART WITH CHANGING COLORS?
    By Hector in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 05-14-2006, 12:45 PM
  4. macor to create chart/graph for a specific row of data
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-07-2006, 04:20 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