+ Reply to Thread
Results 1 to 4 of 4

How to select data for x-axis in macro plot

  1. #1
    Registered User
    Join Date
    06-25-2010
    Location
    Chi Town
    MS-Off Ver
    Excel 2007
    Posts
    13

    How to select data for x-axis in macro plot

    I tried recording a macro that generates a scatter plot using one column as the x-axis data, and several columns for y. The plots come out correctly when I record the macro, but when I apply it to new data, it plots it by index, rather than data points. For example:

    Correct:
    x...................y
    1.4928............1394.23
    2.3459............2492.42
    3.9846............142.42

    Macro:
    x.................y1.................y2
    1..............1.4928...........1394.23
    2..............2.3459...........2492.42
    3..............3.9846............142.42

    How can I specify the x-axis for the macro, when I already tried to do it during the recording? I found I can do it by hand, but it is tedious; I have to select each series at a time and re-select the x-axis data, making a macro obsolete. Here is my code for one of the plots, and I have attached the graphs.

    Please Login or Register  to view this content.

    The workbook originally has a ton of data, but is reduced significantly when the macro is run. I've also attached what the graph looked like when I recorded the macro, and what it should look like. Thank you.
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by elementalsurf7; 07-01-2010 at 03:22 PM. Reason: added workbook

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,021

    Re: How to select data for x-axis in macro plot

    A sample workbook would be more useful. Also, I assume you are actually using 2007 (rather than the 2003 shown in your profile) since that code wouldn't work in 2003?
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Registered User
    Join Date
    06-25-2010
    Location
    Chi Town
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: How to select data for x-axis in macro plot

    I figured out how to get all of them in order using the longer code, and setting the range to:

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.
    Last edited by elementalsurf7; 07-01-2010 at 03:21 PM.

  4. #4
    Registered User
    Join Date
    04-01-2009
    Location
    Belgium, Brussels
    MS-Off Ver
    Excel 2003
    Posts
    1

    Re: How to select data for x-axis in macro plot

    Helped me out thx!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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