+ Reply to Thread
Results 1 to 10 of 10

Error 1004

  1. #1
    Registered User
    Join Date
    06-27-2014
    Location
    Stockholm, Sweden
    MS-Off Ver
    2010
    Posts
    72

    Error 1004

    Hello,

    This is my code:
    Please Login or Register  to view this content.
    It creates the correct chart but gives me the 1004 error and says "The Specified Dimension is not valid for the current chart type.". How come the code works but still gives me that error? I know it has something to do with the Range variable. Is there something else I should write instead of "ActiveCells"? What I want it to do is to create the chart when I press ctrl+Q from the cells that I've selected


    Thanks in advance,
    Joachim

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Error 1004

    Try changing last line to
    Please Login or Register  to view this content.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Error 1004

    Try this.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    06-27-2014
    Location
    Stockholm, Sweden
    MS-Off Ver
    2010
    Posts
    72

    Re: Error 1004

    When I try Source:=Selection, I get error 13 saying "Type mismatch". But the code still works. This is very strange :p

  5. #5
    Registered User
    Join Date
    06-27-2014
    Location
    Stockholm, Sweden
    MS-Off Ver
    2010
    Posts
    72

    Re: Error 1004

    And with Source:=Range("ActiveCells") I get the same error as I started with (I tried removing selection before I posted on this forum).

  6. #6
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Error 1004

    Do you actually need that line in at all? It's already created the chart based on the active selection...

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

    Re: Error 1004

    Is "ActiveCells" and named range or are you trying to code for the currently selected cells?

    If it's the currently selected cells then you will have problems as the Selection change to a chart object when you add chart and select it.

    I don't see AddChart2 as a valid method in xl2010. So either you have xl2013 or that is a typo.
    Cheers
    Andy
    www.andypope.info

  8. #8
    Registered User
    Join Date
    06-27-2014
    Location
    Stockholm, Sweden
    MS-Off Ver
    2010
    Posts
    72

    Re: Error 1004

    Using xl2013 on this computer (Was using 2010 when I created the account on a different computer). I'm trying to create a chart from the currently selected cells.

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

    Re: Error 1004

    I can not test AddChart2 at work. but code prior to change worked in xl2010.

    Please Login or Register  to view this content.
    As Olly says the newly added chart should use the selected cells as data source.

  10. #10
    Registered User
    Join Date
    06-27-2014
    Location
    Stockholm, Sweden
    MS-Off Ver
    2010
    Posts
    72

    Re: Error 1004

    Thank you Andy! Worked out perfect.

+ 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] VBA Error: Runtime Error 1004: AutoFilter method of Range class failed
    By jl22stac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2013, 07:27 PM
  2. [SOLVED] Getting Error 1004 Object or Application Defined Error - Code to rearrange data
    By BlazzedTroll in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 06-10-2013, 12:10 PM
  3. Error "run-time Error '1004': General Odbc Error
    By D4WNO77 in forum Access Tables & Databases
    Replies: 2
    Last Post: 07-16-2012, 09:55 AM
  4. Error 75 File/Path access error, sometimes Error 1004
    By smokebreak in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 02-16-2011, 02:35 PM
  5. [SOLVED] run-time error '1004': Application-defined or object-deifined error
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-10-2005, 05: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