+ Reply to Thread
Results 1 to 11 of 11

Macro - Runtime Error 1004

  1. #1
    Registered User
    Join Date
    10-07-2008
    Location
    London
    Posts
    6

    Macro - Runtime Error 1004

    Would really appreciate some help on an issue I am facing especially being very new to macros. I have tried but not been successful in getting excel to ignore the error messages or correcting the code.

    Any help would be gratefully appreciated, thanks

    Here goes:

    I have a line chart which I created which shows data on one axis. I created a macro which when clicked by the user creates a secondary axis and shows this data on the chart as well. I also have another macro which resets the chart back to one axis and only displays data along that single axis.

    It all works fine except if you click the macro button twice (either for it to show the secondary axis and data or if you click the reset button twice). I get the following error message:

    Runtime Error '1004':
    Unable to set the AxisGroup property of the Series class

    Here's the VBA code (error code highlighted in bold):

    Please Login or Register  to view this content.
    Last edited by Evian; 10-07-2008 at 01:49 PM.

  2. #2
    Registered User
    Join Date
    10-07-2008
    Location
    London
    Posts
    6
    For the reset button I get the following issue:

    Runtime Error '1004':
    Method 'SeriesCollection' of object' _Chart' failed

    VBA Code:

    Please Login or Register  to view this content.
    Last edited by Evian; 10-07-2008 at 06:10 AM.

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,427
    Does the range being plotted contain empty or error cells?

    Can you post example file.
    Cheers
    Andy
    www.andypope.info

  4. #4
    Registered User
    Join Date
    10-07-2008
    Location
    London
    Posts
    6
    The range does not contain any empty or error cells.

    The macro creates the secondary axis and draws data from a hidden table. What I believe it is trying to do is recreate the secondary axis a second time when you click it twice which is not necessary.
    Last edited by Evian; 10-07-2008 at 08:12 AM.

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,427
    Your code runs fine for the example workbook

  6. #6
    Registered User
    Join Date
    10-07-2008
    Location
    London
    Posts
    6
    The issue is if you click either macro button twice (don't understand why anyone would but...) it throws up that runtime error which I want it to ignore.

  7. #7
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,427
    Gotcha.

    Add some checks to your code.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    10-07-2008
    Location
    London
    Posts
    6
    Excellent thanks, Andy.

    Any chance you can explain why the error was occurring and what the checks do? Might be useful for others who experience similar issues.

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,427
    The deletion one is easy. If the chart only contains 1 series then referencing the 2nd series will fail. So check chart contains enough data series.

    The AxisGroup property failing on second usage is probably a bug.
    So the code checks the axisgroup valid before setting it.

  10. #10
    Registered User
    Join Date
    10-07-2008
    Location
    London
    Posts
    6
    I now have another issue:

    The file works perfectly but when I sent it out to colleagues it gets zipped and when the file is opened it gets remained from:

    CRT Rebate Savings Tracker September 2008.xls

    to

    CRT Rebate Savings Tracker September 20081.xls

    The change being that the file name adds in an extra digit on the end. The implication of this is that "Subscript out of range" error occurs if you click the button twice which I believe is because the file names no longer match up.

    Is there anyway to ensure that whatever the file name ends up as, that it picks this up rather than the default:

    CRT Rebate Savings Tracker September 2008.xls

  11. #11
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,427
    No idea why the file is being renamed.

    But you can modify your code so file name does not matter.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

+ 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 splitt texts into words? (collecting word and compounds)
    By wali in forum Excel Programming / VBA / Macros
    Replies: 53
    Last Post: 02-03-2008, 04:06 AM
  2. vba to change macro file name
    By blackstar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 12-02-2007, 12:14 AM
  3. Conditional formatting macro (highlight macro)
    By c991257 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-09-2007, 02:46 PM
  4. country finder lookup macro
    By theghost in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2007, 10:41 PM
  5. Need macro to move down & select next visible row
    By Fartnuckles in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-25-2006, 10:02 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