+ Reply to Thread
Results 1 to 2 of 2

Chart SeriesCollection(i).XValues "error 1004: invalid parameter"

  1. #1
    Registered User
    Join Date
    01-08-2016
    Location
    united states
    MS-Off Ver
    MS office 2013
    Posts
    3

    Chart SeriesCollection(i).XValues "error 1004: invalid parameter"

    Hi everybody, I met a problem when creating multiple series in one chart using a macro. All the series have the same range for X axis but different range for Y axis. The number of series is a variable, and I tried to define the X and Y axis ranges for each series respectively using a loop.
    Currently there're 12 series to be plotted. When I run the macro only the first 9 series can be plotted successfully, then it crashes while creating the 10th series, saying "error 1004: invalid parameter".

    Here's the code:


    Dim i, A, startrow as Integer
    Set chart1 = Charts.Add
    With chart1
    'create and insert the chart as a new sheet after the first sheet
    .ChartType = xlXYScatterLinesNoMarkers
    .Location where:=xlLocationAsNewSheet, Name:="overall"
    .Move after:=Sheets(2)
    'set source data for each series
    A = 12
    startrow = 75
    For i = 1 To A
    .SeriesCollection(i).XValues = Range(Sheets(1).Cells(startrow + 1, 3), Sheets(1).Cells(startrow + 1000, 3)
    .SeriesCollection(i).Values = Range(Sheets(1).Cells(startrow + 1, 12 + A + i), Sheets(1).Cells(startrow + 1000, 12 + A + i))
    Next i
    End With

    I've run the macro several times, every time it stopped while doing the 10th loop of ".SeriesCollection(i).XValues = Range(Sheets(1).Cells(startrow + 1, 3), Sheets(1).Cells(startrow + 1000, 3)" with a error 1004 of invalid parameter.
    I'm not sure if this is because there're some empty cells in the designated range for both the X and Y axis (I made the range larger because new data will come in for many times later and I hope the chart can automatically update with the new data). However, since it worked fine for the first 9 series, I doubt the empty cells is the cause of the error.

    Has anybody encountered similar issues? Any comments or suggestions will be appreciated, thanks in advance!!

  2. #2
    Forum Contributor
    Join Date
    01-08-2016
    Location
    Cagayan De Oro City, Philippines
    MS-Off Ver
    2013
    Posts
    152

    Re: Chart SeriesCollection(i).XValues "error 1004: invalid parameter"

    Hi

    Charts are a pain sometimes .......

    try this link
    LINK

    the solution is in the comments for a similar problem....

+ 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. [SOLVED] getting "invalid qualifier" error while using " .text"
    By joy3939 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-26-2014, 02:41 PM
  2. Error "Invalid Parameter" in Charting VBA Code
    By JieJenn in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-21-2011, 02:34 PM
  3. ActiveChart.SeriesCollection(1).Name = "=Sheet1!R15C11"--error
    By ckb in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-16-2007, 05:48 PM
  4. [SOLVED] SeriesCollection(i) and XValues= Array() error
    By MJKulangara in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 04-12-2006, 02:55 PM
  5. Can't set Chart's SeriesCollection XValues
    By BW in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-26-2005, 01:05 AM
  6. (Un)usual "cannot set Xvalues" error message
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-27-2005, 06:06 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