XL: Macro to Create a Bubble ChartID: Q107729
|
In Microsoft Excel, you can write a macro to create a bubble chart. Bubble charts are similar to xy (scatter) charts; however, instead of having uniform markers where the pair of x and y values intersect, these points are marked with circles that indicate the relative magnitude of the values in a third series.
If you are using Microsoft Excel 97 or Microsoft Excel 98 Macintosh
Edition, you do not need to use a macro to create a bubble chart. These
versions of Microsoft Excel include built-in support for bubble charts.
If you are using Microsoft Excel 5.0 or 7.0, please see the following
article in the Microsoft Knowledge Base for a Visual Basic macro to create
a bubble chart:
Q139662 : XL: How to Use a Visual Basic Macro to Create a Bubble Chart
Microsoft provides programming examples for illustration only, without
warranty either expressed or implied, including, but not limited to, the
implied warranties of merchantability and/or fitness for a particular
purpose. This article assumes that you are familiar with the programming
language being demonstrated and the tools used to create and debug
procedures. Microsoft support professionals can help explain the functionality
of a particular procedure, but they will not modify these examples to
provide added functionality or construct procedures to meet your specific
needs. If you have limited programming experience, you may want to contact
the Microsoft fee-based consulting line at (800) 936-5200. For more
information about the support options available from Microsoft, please see
the following page on the World Wide Web:
http://www.microsoft.com/supportnet/refguide/
A1: Make Bubble
A2: =ECHO(FALSE)
A3: =MESSAGE(TRUE,"Gathering information........")
A4: =GET.DOCUMENT(1)
A5: =ACTIVATE?()
A6: =GET.DOCUMENT(1)
A7: =ACTIVATE(A4)
A8: =SELECT(SELECTION())
A9: =MESSAGE(TRUE,"Creating the bubbles for chart.........")
A10: =FOR("Count",1,COUNT(SELECTION()))
A11: =ACTIVE.CELL()*50
A12: =ACTIVATE("Bubble.xlm")
A13: =SELECT("1")
A14: =DISPLAY(FALSE)
A15: =FORMAT.SIZE(A11,A11)
A16: =COPY()
A17: =DISPLAY(TRUE)
A18: =ACTIVATE(A6)
A19: =SELECT("s1p"&Count)
A20: =PASTE()
A21: =ACTIVATE(A4)
A22: =SELECT(,"R[1]C")
A23: =NEXT()
A24: =ACTIVATE(A6)
A25: =MESSAGE(TRUE,"One moment please.......")
A26: =SELECT("")
A27: =MESSAGE(TRUE)
A28: =RETURN()
A1: Name of the macro.
A2: Disables screen updating.
A3: Displays a message.
A4: Returns the name of the active document.
A5: Presents dialog box of all open documents.
A6: Returns the name of the active document
A7: Activates the document whose name is in cell A3.
A8: Reselects the current selection.
A9: Displays a message.
A10: Sets up a FOR loop to iterate through the selection.
A11: Calculates the width & height of circle for this point.
A12: Activates the macro sheet.
A13: Selects the circle that is on the macro sheet.
A14: Displays the results of formulas.
A15: Resizes the circle to the correct dimensions.
A16: Copies the circle.
A17: Restores the formulas to the cells.
A18: Activates the chart.
A19: Selects a point on the chart.
A20: Pastes the circle on the point.
A21: Activates the document whose name is in cell A3.
A22: Activates the next cell in the selection.
A23: Returns to the beginning of the loop.
A24: Activates the chart.
A25: Displays a message.
A26: Deselects the final point in the chart.
A27: Resets the status bar.
A28: Ends the macro.
A1: B1: Gross Revenues C1: Net Income D1: # of Plants
A2: East B2: 831191 C2: 35427 D2: 26
A3: West B3: 622199 C3: 54263 D3: 13
A4: North B4: 153794 C4: 80881 D4: 40
A5: South B5: 711327 C5: 33872 D5: 35
"User's Guide 1," version 4.0, Chapter 14
"User's Guide 2," version 4.0, Chapter 7
"User's Guide," version 3.0, Chapters 13 and 19
Additional query words: 4.00a
Keywords : kbmacro kbprg kbprb
Version : WINDOWS:3.0,4.0,4.0a; OS/2:3.0; MACINTOSH:3.0,4.0
Platform : MACINTOSH OS/2 WINDOWS
Issue type : kbhowto kbinfo
Last Reviewed: July 9, 1999