+ Reply to Thread
Results 1 to 18 of 18

Error 424 when setting chart axis values

  1. #1
    Forum Contributor
    Join Date
    04-22-2014
    Location
    Turrialba, Costa Rica
    MS-Off Ver
    Excel 2010
    Posts
    108

    Question Error 424 when setting chart axis values

    Hello.
    I have this code to export a query to excel and create a chart.
    The code is working fine:
    Please Login or Register  to view this content.
    However, when I type beneat this code to set set maximun and minimum axis carth values
    Please Login or Register  to view this content.
    the following line always there is the Object required error '424':
    Please Login or Register  to view this content.
    I hope someone can help,

    All the best

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Error 424 when setting chart axis values

    What is Chart1? Is that a worksheet, a chart sheet, or something else? Is "Axis_max" a named range in your file? Does it evaluate to a valid value in your worksheets?

    (This is why we usually end up asking people to attach their Excel file.)

    BTW you have repeated the exact same line of code twice. That will not cause your error, but does not appear to be what you intended.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Contributor
    Join Date
    04-22-2014
    Location
    Turrialba, Costa Rica
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Error 424 when setting chart axis values

    6StringJazzer

    Many thanks for your reply.

    Chart1 is the name of Chart assigned by the code
    The Chart1 is in the Worksheet

    I found this code from Shai Rado and I juste adapted it for me
    https://stackoverflow.com/questions/...tal-x-axis-vba

    Please Login or Register  to view this content.
    However, I need VBA to read minimum and maximum values to set the axis values.
    Can you tell me what is the meaning of instruction CrossesAt = 20?

    I also attach a file with my qry_task sheet (with data) and my chart.
    The file has a macro I recorded to format my chart.
    I really appreciate if you can edit the macro code to be as a complete VBA code.

    Many thanks in advance.
    Attached Files Attached Files
    Last edited by gipsyfkls14; 08-28-2018 at 11:37 PM. Reason: eliminate word here

  4. #4
    Forum Contributor
    Join Date
    04-22-2014
    Location
    Turrialba, Costa Rica
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Error 424 when setting chart axis values

    Hello.

    It's been over three days with no more replies.
    I am still working this on my own, but, I will still appreciate any help to fix my problem.

    Thanks in advance!

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

    Re: Error 424 when setting chart axis values

    your original code fails because you are trying to set the category axis. change xlCategory to xlValue and it should work.
    Cheers
    Andy
    www.andypope.info

  6. #6
    Forum Contributor
    Join Date
    04-22-2014
    Location
    Turrialba, Costa Rica
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Error 424 when setting chart axis values

    Andy. I really appreciate your quick reply.
    I'm going to test your suggestion and I'll let you know about it.
    Cheers

  7. #7
    Forum Contributor
    Join Date
    04-22-2014
    Location
    Turrialba, Costa Rica
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Error 424 when setting chart axis values

    Andy Pope. Again I appreciate your help.

    I tested your suggestion within "With ch" in my code (below) and again I failed: "ERROR 424 and object is required" in line:
    Please Login or Register  to view this content.
    I think I don't know how to reference it.

    Let me know about my project.

    In Access I have a Form with 2 textboxes and one command button.
    In txttask_plot, user types plot value (numeric)
    In txttask_from, the user selects day1 (Date)
    In txttask_to, the user selects day1 (Date)
    The command button runs a code that works fine exporting the query and creating the Chart

    This is my code in my command button:
    Please Login or Register  to view this content.
    What I'm looking for is for VBA to execute the following:
    Read range B2(to the last row) in the query minimum and maximum values to set values range (or escale?) in the primary vertical axis
    Read range C2(to the last row) in the query minimum and maximum values to set values range (or escale?) in the secondary vertical axis
    Therefore, any time I export a query to Excel VBA will set the minimum and maximum values in Primary and Secondary Axes values

    I have been googling for the last 3 days to find a solution with no success.

    I really appreciate your help.

    Cheers

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

    Re: Error 424 when setting chart axis values

    Attached example creates chart and sets axes

    If you are running this from Access I assume you are early binding excel in order for the excel constants to have correct values.
    If you are using late binding then you will need to assign values to enumerate items such as

    xlValue, xlCategory, xlPrimary, msoElementLegendBottom
    Attached Files Attached Files

  9. #9
    Forum Contributor
    Join Date
    04-22-2014
    Location
    Turrialba, Costa Rica
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Error 424 when setting chart axis values

    Andy Pope. Many thanks.
    I am running my code from MS Access.

    This is my code form MS Access:
    Please Login or Register  to view this content.
    However, I have been unable to set minimun and maximun values in primary and secondary axes in my chart and I am still working.

    On the other hand, the excel file attached is very useful and educational to create graphics.
    I appreciate your valuable help.

  10. #10
    Forum Contributor
    Join Date
    04-22-2014
    Location
    Turrialba, Costa Rica
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Error 424 when setting chart axis values

    Andy Pope.
    Since 01/09/2018 I am studying how to use early binding and late binding.
    In MS Acess VBA Editor I checked Microsoft Excel 16.0 Object Library
    In MS Excel VBA Editor I checked Microsoft Access 16.0 Object Library

    For the late binding I found the information on this links:
    https://www.devhut.net/2012/04/19/ms...ords-to-excel/
    http://www.granite.ab.ca/access/latebinding.htm
    http://www.dyalog.com/uploads/confer...ndexamples.htm

    I am a newbie on this respect.

    Now my code exports to excel the query and creates the chart with:
    Primary and secondary axis values
    Labels values in the axis
    Chart Background Colour

    The code I used is almost the same in MS Excel.
    So far, I could not find the instructions to set the minimum and maximum values for the primary axis and for the secondary axis.

    In Excel, your code works well to set the minimum and maximum values of the primary axis and the secondary axis.
    My problem is that I have not been able to adjust your lines of code to Access VBA.

    Please, could you tell me which website I can visit to find the solution to my problem?
    Cheers

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

    Re: Error 424 when setting chart axis values

    Not sure what to tell you.

    The latest code you posted does not include any code to set the chart's axes.
    If you are using late binding then as I said previously you will need to define variables to act in place of the excel constants which are available when early binding.

  12. #12
    Forum Contributor
    Join Date
    04-22-2014
    Location
    Turrialba, Costa Rica
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Error 424 when setting chart axis values

    Andy Pope. I really appreciate your reply.
    The below code has lines ('Set maximum and minimum axis values) to set minimum and maximum axis values from the query.

    Please Login or Register  to view this content.
    However, in the chart:
    Primary axis minimum value starts at 0.
    Primary axis maximum value is not query value.
    Secondary axis minimum value starts at 0.
    Secondary axis maximum value is not query value.

    Many thanks in advanced

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

    Re: Error 424 when setting chart axis values

    Again your code does not incorporate the code I provided to set those properties, so no surprise it not doing anything.

    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    04-22-2014
    Location
    Turrialba, Costa Rica
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Error 424 when setting chart axis values

    Andy Pope.
    I understood that your code is for Excel. Your code works excellent in Excel.
    I really apologize for omitting your code in my previous posts.

    I have been trying to write your VBA Excel code within my code in MS Access VBA

    Please Login or Register  to view this content.
    But any time I click th command dbutton VBA coloured in blue the underlined words:
    .MinimumScale = Application.WorksheetFunction.Min(dataValuesPrimary)
    and displays this message: "MS Access VBA Compilation Error Method or data member not found."

    I used Dim ch As Object ''Excel.Chart instead of Dim cht As Chart and VBA displays same error
    I used Dim cht As Chart instead of Dim ch As Object ''Excel.Chartand VBA displays same error

    I have been googling on how to fix such error with no success.

    Again I really appreciate your help.
    Cheers

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

    Re: Error 424 when setting chart axis values

    The application refers to the application the code is being executed within, which in your case is Access and not Excel.
    If you where to use the Excel worksheet functions you would need to reference the excel object

    Please Login or Register  to view this content.
    But in your previous code you were determining min and max with access functions so I don't think you need to use that part of excel at all

    I will say it one more time, if you are late binding then you need to ensure the excel enumeration you use has the correct values.

  16. #16
    Forum Contributor
    Join Date
    04-22-2014
    Location
    Turrialba, Costa Rica
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Error 424 when setting chart axis values

    Andy Pope.
    Thank you for your time and effort in helping me.

    I tested you excel code in excel and works perfectly.
    I'm worried because I have been unable to run in Access the code you provided.
    The attached image shows in yellow 'Error, 438 Object doesn't support this property or method.' error438_code_export_qry_chart_primary_secondary_axis.jpg. I can provide the code if needed.

    Although I have been studying about early binding and late binding I still do not know which code lines indicate if it is early binding or late binding.
    I am completely stumped on a VBA setting vertical axis min and max values.:confused.

    Cheers

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

    Re: Error 424 when setting chart axis values

    Early binding means you have included a reference to the library of the object, in your case the excel application. This is done within VBE using Tools > References.
    If you have not done that then you are using late binding.

    You code fails because you have used nested With syntax where the objects being referenced are not nested,
    ,Axes is not an object of the .seriescollection object.

    Please Login or Register  to view this content.

  18. #18
    Forum Contributor
    Join Date
    04-22-2014
    Location
    Turrialba, Costa Rica
    MS-Off Ver
    Excel 2010
    Posts
    108

    Re: Error 424 when setting chart axis values

    Andy Pope.

    Those two lines of code have kept me with a headache for a week
    Now my code runs.
    Thank you very much for your help.

+ 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. Replies: 3
    Last Post: 04-09-2018, 10:42 AM
  2. [SOLVED] First time setting up a chart with dynamic axis....and I stink at it
    By Jocamo in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 06-20-2017, 10:29 AM
  3. Setting Chart Y axis to start at no less than 0
    By beerbud89 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-03-2013, 10:56 AM
  4. Dynamic Setting for Chart Axis Minimum
    By life2539 in forum Excel General
    Replies: 1
    Last Post: 09-20-2011, 07:30 PM
  5. Runtime Error 1004 when Setting Setting Series Values
    By tonymctigue in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 04-09-2010, 10:05 AM
  6. Setting a Minimum X-axis Value to Stacked Bar Chart
    By Juhanen II in forum Excel General
    Replies: 1
    Last Post: 04-21-2009, 11:24 AM
  7. [SOLVED] Error when setting chart Axis value
    By Job in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-06-2005, 12: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