Reliable Spreadsheet Solutions - Call Now 281-379-2000 Microsoft Excel - Visual Basic for Applications Consultant Reliable Spreadsheet Solutions - Call Now 281-379-2000 !
PROFESSIONAL SOFTWARE DEVELOPMENT
Reliable Excel VBA Solutions !
 
Microsoft Office : Excel - Visual Basic for Applications [ VBA ] Software 

Beyond Technology

Insight for Microsoft Excel POWER-Users
  Excel Solutions Letter ® FREE  excel solutions letter
Spreadsheet Power-User Tips
  Enable ease and consistency of data entry with a dropdown list of possible entries for a range  dropdown list in cell
  Designing an array formula that functions similar to a VLOOKUP function with multiple criteria and returns a text entry  mult-criteria text lookup
  How Excel workbooks become bloated and what can be done about it  spreadsheet bloat
  Spreadsheet Power-User Tips  more ...
Getting to Know Microsoft Visual Basic for Applications
  Decision Structure that conditionally executes the embedded code  if...then[...else]
  If you are new to VBA and trying to get a handle on programming, this is a MUST READ article for you!  what are variables ?
  Discover a special, more flexible variety of arrays  dynamic arrays
  Getting to Know Microsoft Visual Basic for Applications  more ...
Microsoft Excel Advanced VBA - Just for Geeks
  MUST SEE!  A named range that expands and contracts automatically based on the number of items in the source data table  dynamic named ranges
  MUST SEE! How to identify the last used row in an Excel worksheet  finding real last cell
  Creating charts that adapt as the size of the source data range varies  charting dynamic data
  Microsoft Excel Advanced VBA - Just for Geeks  more ...
Excel Spreadsheet Tools and Tutorials
  Mortgage & Auto Loan Payment Calculator » Amortization with Excel Spreadsheets  amortization guide
  Breakeven Analysis with Excel Spreadsheets Tutorial  breakeven analysis
  Permutations & Combinations with Excel Spreadsheets  combinatorics
  Standard Deviation in Excel Spreadsheets Tutorial  standard deviation
  Weighted Average in Excel Spreadsheets Tutorial  weighted average


Microsoft Excel VBA Custom Application Development
  Microsoft Excel VBA Custom Application Development  excel vba customization
  Microsoft Excel VBA Professional Development Experience  professional experience
  Microsoft Excel VBA Custom Application Development  project request form
Microsoft Excel VBA Solutions : Real-World Project Profiles
  How deep is your data?  engineering analysis
  Financial reporting can be a challenging endeavor.  financial reporting
  To anticipate customers needs is to be rewarded with their business.  sales forecasting
  Are time-hungry paperwork tasks building up on you?  automated billing
  An Engineer-in-a-Box  engineering design
  Partial List of Beyond Technology Clients - Past & Present  clients - past & present


Reliable Spreadsheet Solutions - Call Now 281-379-2000 !
  Visitors' Comments  gratuitous kudos
  Add to Favorites 
  Reliable Spreadsheet Solutions - Call Now 281-379-2000 !  e-mail contact

20831 Rosehill Church Rd
Tomball, Texas 77377


Charting Dynamic Data

Rodney POWELL
Microsoft MVP - Excel
need a developer for
your excel project ?
go here
Prerequisite:

Click on the link for dynamic named ranges if you aren't already familiar with it, you'll need this information to proceed.




A challenge arises when you want to use a dynamic range in a chart to accomodate when the number of items to be graphed changes.

First, let's chart a simple set of monthly values. We'll want to have the chart automatically extend the data series whenever new months are added in the source range.


Microsoft Excel : Charting Dynamic Data


A good way to approach or problem may be to look at what wouldn't work.

Incorrect Approach #1

Microsoft Excel : Charting Dynamic Data


What we could NOT do is create a dynamic named range, then use it as the source data range for the chart. Referring to the illustration above, we'll create a named range (dynamic or static), Sheet1!rngSource, then provide it to the ChartWizard as the data range.

Microsoft Excel : Charting Dynamic Data


However, instead of leaving the range name, the Excel chart converts the range reference to a static address (i.e., =Sheet1!$A$1:$B$7 ).

Incorrect Approach #2

The next thing we may try is taking the same formula we used in our Define Name dialog and entering it directly into the ChartWizard for the data range.

Microsoft Excel : Charting Dynamic Data


It will be plotted, but just like in the prior example, it fails to have the dynamic characteristic for the charted range to adapt to the varying size of our source range as we add extra data to the table.


How to Make This Work

Now that you understand the challenge. Let's look at a way to tackle it. The key will be in editing the SERIES formula for the chart.

Do the following:
  • Using the ChartWizard, create a ordinary simple line chart to plot this range ...

    =Sheet1!$A$1:$B$7

  • Create two dynamic named ranges ...

    • Sheet1!rngDate

      =OFFSET(Sheet1!$A$1,1,0,COUNTA(Sheet1!$A:$A)-1,1)

    • Sheet1!rngAmt

      =OFFSET(Sheet1!$A$1,1,1,COUNTA(Sheet1!$A:$A)-1,1)
Notice :

  • The only difference between these two reference formulas is the OFFSET function's 3rd parameter, for column offset.

  • The OFFSET function's 2nd parameter, row offset, has a value of 1, not zero. You'll offset 1 row down from the anchor cell ( being $A$1 ), so the header is NOT included.

Next, click on the line plotted on your chart and you'll see a SERIES in the formula bar.


Microsoft Excel : Charting Dynamic Data


Let's look at the syntax for this SERIES formula:

=SERIES( name_ref , categories , values , plot_order )
  • Name_ref is the name of the data series. Here it is "AMOUNT".

  • Categories is the reference (incl. sheet name) for the range containing the X-coordinate labels. Here it's the dates in Column A.

  • Values is the reference (incl. sheet name) for the range containing Y-coordinate values. Here it will be the dollar amounts in Column B.

  • Plot_order is an integer designating if this series is plotted first, second, third, etc. The chart shown here just plots a single series, therefore this parameter can only be 1.

Finally, we need to edit the SERIES formula and replace the static range addresses for its categories and values parameters with the dynamic named ranges we defined.

  • Replace the categories parameter, Sheet1!$A$2:$A$7
    (2nd argument in SERIES formula), with this reference Sheet1!rngDate

  • Replace the values parameter, Sheet1!$B$2:$B$7
    (3rd argument in SERIES formula), with this reference Sheet1!rngAmt

Your new SERIES formula should look like this:

=SERIES(Sheet1!$B$1,Sheet1!rngDate,Sheet1!rngAmt,1)
IMPORTANT NOTES:

  • Be sure to include the worksheet name in these references ( i.e., Sheet1! ... ).

  • The records must be contiguous (that means, without blank rows). A count of the items in Column A, the Date field, determines the vertical dimension (the height in rows) of the dynamic range in this example.

Having done this, you should be able to go to Row 8 of our example and add Jul-2001 with $ 268 and you'll see it plotted.

Reliable Spreadsheet Solutions - Call Now 281-379-2000 !

Know an even better way? Let me know.

Beyond Technology Custom Application Development
  home Microsoft Excel VBA Custom Application Development  professional consulting Insight for Microsoft Excel POWER-Users  developer tips Visitors Comments  visitor kudos Beyond Technology - Microsoft Solution Provider  e-mail  

Your suggestions and comments are greatly appreciated. Please keep them coming.

Mail to:   rodney@beyondtechnology.com

All terms, product designs, and company names used in this site may be trademarks or registered trademarks of their respective owners, and are hereby acknowledged. © 1996 - 2008 Beyond Technology. All rights reserved.