+ Reply to Thread
Results 1 to 4 of 4

Scatter plot with VBA

  1. #1
    Registered User
    Join Date
    06-17-2010
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    6

    Scatter plot with VBA

    I have data on multiple worksheets and want to draw scatter plots.
    x-values contains data on countries' variables in year 2004-2008
    y-values contains data on countries' FDI receipts in year 2004-2008

    I'm new to VBA and need some help to write a macro to draw scatter plots for each year and a pooled of all year with right x-axis scale (it's not correct on the current example plot) and a linear trend line. Eventually, I don't want plots contain data whether x-data or y-data is missing.
    And can we limit the plotted data within 2 standard deviation only?

    I've done programming on other languages like Matlab, Stata. Any example code will help as I think I can tweak it to work. But I need a start.

    Attached is the example data.

    Your help is very appreciate
    Attached Files Attached Files
    Last edited by trungbui; 07-05-2010 at 11:49 AM.

  2. #2
    Forum Expert pike's Avatar
    Join Date
    12-11-2005
    Location
    Alstonville, Australia
    MS-Off Ver
    2016
    Posts
    5,342

    Re: Scatter plot with VBA

    Hi trungbui,
    Welcome to the forum.
    The best way to start is to use the macro recorder and then critque the code.
    If the solution helped please donate to RSPCA

    Site worth visiting: Rabbitohs

  3. #3
    Forum Expert teylyn's Avatar
    Join Date
    10-28-2008
    Location
    New Zealand
    MS-Off Ver
    Excel 365 Insider Fast
    Posts
    11,375

    Re: Scatter plot with VBA

    Unfortunately, in Excel 2007 the macro recorder is pretty useless when it comes to charts.

    In any case, you will need to prepare a table that has your X and Y values in two distinct columns before anything can be done.

    From your attached file, it is not clear what your X and Y values should be.

  4. #4
    Registered User
    Join Date
    06-17-2010
    Location
    Washington, DC
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Scatter plot with VBA

    Thanks. I got all data into column in a separate worksheet. It's funny how Excel cannot distinguish non-numeric data, I had to do paste special and replace "N/A" with empty cells. If anyone has any working macro that creates multiple charts, I'd love to see.

+ 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