+ Reply to Thread
Results 1 to 5 of 5

Copy Major Units value from graph

  1. #1
    Registered User
    Join Date
    07-21-2015
    Location
    UK
    MS-Off Ver
    2013
    Posts
    55

    Copy Major Units value from graph

    Hi,

    Hoping someone can help. I am new to Excel so would appreciate if anyone can help me write a macro or script for the following. I am using Excel 2016.

    I have a spreadsheet with three tabs:

    Tab1 is called 'CalculatedValues' and contains numerous data values - some that are referenced in graphs in the rest of the spreadsheet
    Tab2 is called 'Graph1' and contains a line graph of data from the tab called 'CalculatedValues'
    Tab3 is called 'Graph2' and contains a line graph of data from the tab called 'CalculatedValues'

    I want a macro that can do the following. This is something that I will run very often as data inputs change frequently. I may also have far more than 2 graphs in the future.


    When I right click on the axis of the graph (numbers on left side of graph) in the tab called 'Graph1', and select 'Format Axis', I want to copy the value in the Major Units box (i.e. 200) and then paste this in cell A1 in tab called 'CalculatedValues'. I then want to do the same for the major axis value from the graph in the tab called 'Graph2' but paste the value in cell A2 in the tab called 'CalculatedValues'.

    Grateful if someone can help me with a macro or VBA script to do this. This is for a very good cause. Please note that I am not a programmer so please be gentle

    Thank you so much

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,834

    Re: Copy Major Units value from graph

    Can you attach the workbook here? What's the good cause?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    07-21-2015
    Location
    UK
    MS-Off Ver
    2013
    Posts
    55

    Re: Copy Major Units value from graph

    How do I attach? More than happy too The cause is for a local charity - I am just doing some work for them

  4. #4
    Registered User
    Join Date
    07-21-2015
    Location
    UK
    MS-Off Ver
    2013
    Posts
    55

    Re: Copy Major Units value from graph

    trial.xlsm

    Attachment now attached. Grateful if someone can help Thank you

  5. #5
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,829

    Re: Copy Major Units value from graph

    Are you familiar with Excel's object model? If not, I would recommend that you become familiar with it (I think the answer to most of these kind of questions is really about how to find the desired object and property/method in the object model): https://msdn.microsoft.com/en-us/lib.../ff194068.aspx

    I'm not sure where you would want it to appear in your code, but the basic ideas will be:
    1) Identifying which chart using the desired_workbook.charts(chart_identifier)
    2) then identifying the axis .axes(xlvalue)
    3) then reading the major unit of that axis .majorunit.
    4) Assign that to a variable or to a cell value.

    Please Login or Register  to view this content.
    You should be able to access the help files for all of those collections, objects, and properties from the object model link above.
    Last edited by MrShorty; 12-30-2015 at 10:43 AM.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

+ 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. Graph with different units of measurement
    By gexxy in forum Excel General
    Replies: 21
    Last Post: 04-15-2015, 01:37 PM
  2. Replies: 3
    Last Post: 11-16-2014, 10:51 PM
  3. major and minor chart units
    By jbates58 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 11-22-2013, 09:04 AM
  4. cost vs units graph
    By asadim in forum Excel General
    Replies: 13
    Last Post: 04-25-2012, 07:43 PM
  5. Mutliple major units in excel axis
    By karthikcoep in forum Excel General
    Replies: 1
    Last Post: 03-22-2010, 12:04 AM
  6. [SOLVED] Changing the scale major unit in a graph
    By Ant in forum Excel General
    Replies: 2
    Last Post: 02-06-2006, 09:45 AM
  7. defining major units on chart axis
    By Nick Turner in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 08-31-2005, 03: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