You are here:

Excel/Using Named Ranges

Advertisement


Question
Hi Bill,

I have already asked a question to Stuart Resnik and he has answered but he has told me what I already know and am stuck at.   Maybe I didn't explain myself well enough?   Anyway the Q & A is below but I'll try and expand it a bit more.

I have a sheet of data in 5 columns.   
I have 4 graphs each graph has 3 cells to the side of it which show the Average, Max and Min.

Each week I add data to the data sheet but then have to redfine the series' of each graph, each Average, each Max and Each Min to include the new data.

Rather than having to redefine 16 seperate cells/ranges I just want to use variables (which I assume is the same as a Name?).   Then all I want to do is to change the numbers in a couple of fields which would in turn change the defined ranges e.g.

Last week the range was =Data!$A$350:$B$414
This week the range is =Data!$A$350:$B$421

I want cell A1 Named "Start" to equal =Data!$A$350
and cell A2 Named "Finish" to equal =Data!$A$414

To update the 16 ranges all I want to do is to change cell A2 to equal =Data!$A$421 then all the ranges automatically update. Is that possible?

I hope that makes sense.

Regards,

Murray

Subject   Excel Formulas
Question   I have an excel workbook with 1 sheet of data and 2 sheets of graphs that use the data.  Each week I add data to the data sheet and then edit the data ranges in the graphs to include the new data for example, =Data!$A$350:$B$414 would become =Data!$A$350:$B$421.  What I would like to do is to use a name in the data range e.g. =Data!Start:Finish then define these names somewhere else so all I have to do is enter the start and finish cells just once.

I also want to do the same kind of thing but with the average function e.g. =average(start:finish) which would give an average of all values between $A$350 and $B$414.   All I have managed to do so far is get the average of these 2 values, $A$350 and $B$414.

--------------------------------------------------------------------------------

Answer   Here's an example. On sheet "data" you have your data that drives the chart. Say it's a column graph. In range A1:A4 you have the labels for the columns, and in B1:B4 you have the values. You've created your chart, and it's called Chart1.

To work with named ranges, e.g., select A1:A4, and choose from main menu: Insert, Name, Define, colAlabels, OK. Now A1:A4 has the range name "colAlabels." Similarly, give B1:B4 the range name "colBdata."

Now go to Chart1 and select the Column series. In the formula bar for Series 1, change the formula that drive the chart to:

=SERIES(,data!colAlabels,Bdata!colBdata,1)

Now, each time the data changes on data sheet, just re-define the range names to fit the new data ranges, and the Chart will pick up the new data ranges.

As for your 2nd question... if you've given the range name "start" to the upper-left corner cell of a range, and the range name "finish" to the lower-right cell of that range, and you want a formula to return the average of the entire range, the formula is:

=AVERAGE(start:finish)  

Answer
EXCEL can create dynamic ranges which means the area the range name refers to will change based on the amount of data.  So, if you have data in A1:A10, for example, and have a range named TEST then TEST will "select" A1:A10.  Add data to A11 and to A12 and then TEST will "select" A1:A12.  It sounds like this is what you want/need.

To explain how to do this takes a good bit of typing and more than I want to type.  So, you can GOOGLE for

"Dynamic range names in EXCEL" and find a lot of detailed info on this subject.  Then your graphs can just reference range names.

Hope this helps.
About Excel
This topic answers questions related to Microsoft Excel spreadsheet (or workbook) stand-alone or Mircrosoft Office Excel including Excel 2003, Excel 2007, Office 2000, and Office XP. You can get Excel help on Excel formulas(or functions), Excell macros, charting in Excel, advanced features, and the general use of Excel. This does not provide a general Excel tutorial nor the basics of using a spreadsheet. It provides specific answers to using Microsoft Excel only. If you do not see your Excel question answered in this area then please ask an Excel question here

Excel

All Answers


Answers by Expert:


Ask Experts

Volunteer


Bill

Expertise

I can provide help with most all EXCEL questions and most all questions about writing EXCEL macros. I have been developing macros for about 10 years in EXCEL and have switched to it from Lotus 1-2-3 after about 10 years of writing macros in it. Typically, I will not write a macro for you unless it is very short because of all the details a macro has to know about to work every time all the time. Please understand that I do not know it all and will be the first to say so. As politely as possible, I don't write macros for people on this site who need one, want one, seem to imply that they need one, and/or seem to think I am expected to write one UNLESS they are very short, quick, and simple. 99% of all macros are more involved than what you think and rarely am I provided with enough specific and complete details to have the code work the first time and every time. This typically means too many follow-up emails, and subsequent macro changes due to lack of specific details, just to get those details so that the macro would work, all of which is on my own free time. The voice of experience from responding to many questions from people who ask me to write a macro for them from this site tells me this. I don't mean to come across as unhelpful but macros are usually very specific and without ALL of the specifics the macro I would write will not address all of your needs and the layout, location, formatting, conditions, etc. of your data and any related files the macro would have to work with. What seems like a simple task to you is almost always more involved than what you think to have the macro ALWAYS work in EVERY situation. If you have a macro you have already written and have a question about it then perhaps I could help with that. I am sure and hope you can and do understand.

©2012 About.com, a part of The New York Times Company. All rights reserved.