+ Reply to Thread
Results 1 to 10 of 10

VBA creating chart and set data range

  1. #1
    Registered User
    Join Date
    09-15-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    35

    VBA creating chart and set data range

    the pasted code works for the first two pie charts but it gets caught on the third
    on this line ActiveChart.SeriesCollection(1).Values = datarange2
    any advice?


    Please Login or Register  to view this content.

  2. #2
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: VBA creating chart and set data range

    Hello;

    so, "gets caught" can mean a bunch of things....do you get an error?...does the macro actually hang and you have to close XL?....
    Ernest

    Please consider adding a * if I helped

    Nothing drives me crazy - I'm always close enough to walk....

  3. #3
    Registered User
    Join Date
    09-15-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    35

    Re: VBA creating chart and set data range

    Hi Judgeh,

    Runtime error: Invalid Parameter
    A blank chart is created with no data.
    I appreciate the help.

  4. #4
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: VBA creating chart and set data range

    my guess would be that either variable "d" or "f" are not valid for the range...without see the data I'm just guessing...

  5. #5
    Registered User
    Join Date
    09-15-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    35

    Re: VBA creating chart and set data range

    what do you mean by "not valid for the range"?
    When I run line by line d is 63 and f is 8

  6. #6
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: VBA creating chart and set data range

    sorry, just wondering if the range(Cells(63,18),Cell(63,25)) is a valid range for the chart....can you upload a file with no company confidential info?...

  7. #7
    Registered User
    Join Date
    09-15-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    35

    Re: VBA creating chart and set data range

    Thanks for looking into this!
    Last edited by ajm1991; 11-04-2014 at 03:08 PM.

  8. #8
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: VBA creating chart and set data range

    this seems to work...

    I added a line that chose a field in your dataset. I looked like the first 2 passes it was pick up data when you created the chart and then "changed" the dataset. BUT, the 3rd time it didn't seem to have a dataset, so I told XL to chose the dataset where the current cell was and that seem to work....it's definitely not my preferred method....

    hope this helps....


    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    09-15-2014
    Location
    California
    MS-Off Ver
    2010
    Posts
    35

    Re: VBA creating chart and set data range

    hmmm weird. how did you figure out that was the issue?

  10. #10
    Forum Expert judgeh59's Avatar
    Join Date
    02-07-2013
    Location
    Boise, Idaho
    MS-Off Ver
    Excel 2016
    Posts
    2,310

    Re: VBA creating chart and set data range

    I stepped through the code (F8) and watch how everything was being created....I noticed that the 1st 2 times after the Chart.add the chart was created using data but the 3rd time, no data....so, knowing that XL will attempt to create a chart with a dataset using a single cell and contiguous data, I forced it....

+ 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. Creating a dynamic data range for a chart
    By martinrt in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 11-22-2013, 03:03 PM
  2. Creating a chart which doesn't display a specific range
    By Oddball in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 10-08-2010, 05:27 AM
  3. Creating chart by passing sourcedata as variable range
    By lavi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 09-07-2010, 09:18 AM
  4. [SOLVED] creating range for chart
    By tony_bender@yahoo.com in forum Excel General
    Replies: 1
    Last Post: 05-12-2006, 02:10 PM
  5. Can I use named range in data range box when creating pie chart?
    By BJackson in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 08-17-2005, 01: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