Skip to main content

How to define range based on another cell value in Excel?

Author: Sun Last Modified: 2020-06-24

To calculate a range of values is easy for most of Excel users, but have you ever tried to calculate a range of values based on the number in a specific cell? For example, there is a column of values in column A, and I want to calculate the number of values in column A based on the value in B2, which means that if it is 4 in B2, I will average the first 4 values in column A as below screenshot shown. Now I introduce a simple formula to quickly define range based on another cell value in Excel.
doc define range by cell value 1

Define range based on cell value

arrow blue right bubble Define range based on cell value

To do calculation for a range based on another cell value, you can use a simple formula.

Select a blank cell which you will put out the result, enter this formula =AVERAGE(A1:INDIRECT(CONCATENATE("A",B2))), and press Enter key to get the result.
doc define range by cell value 2


1. In the formula, A1 is the first cell in the column you want to calculate, A is the column you calculate for, B2 is the cell you calculate based on. You can change these references as you need.

2. If you want to do summary, you can use this formula =SUM(A1:INDIRECT(CONCATENATE("A",B2))).

3. If the first data you want to define is not in first row in the Excel, for instance, in cell A2, you can use the formula as this: =AVERAGE(A2:INDIRECT(CONCATENATE("A",ROW(A2)+B2-1))).
doc define range by cell value 2

Quickly Count/Sum cells by background or format color in Excel

In some cases, you may have a range of cells with multiple colors, and what you want is to count/sum values based on same color, how can you quickly calculate?
With Kutools for Excel's Count by Color, you can quickly do many calculations by color, and also can generate a report of the calculated result.  Click for free full featured trial in 30 days!
doc count by color 1
Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days.

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Comments (21)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
But If I want to sum a column range(say l7:l7800) out of the range d7:ct9000 based on the condition in column a(a7:a9000) and column b(b7:b9000). How will I do it. Please advise
This comment was minimized by the moderator on the site
Is there a way to create a dynamic ranged view, that will isolate all orders from a specific client within a list of clients? I have looked at multiple videos and none actually do what I need it to do. Is there a way to do this or would I need to pull the needed info into a controlled table and use the information from that table?
This comment was minimized by the moderator on the site
Hi, CareTaker. I do not get your question clearly. Could you describe your question or upload a file to show the quetion in details? But I recomend a utility called Data Association for you, maybe can help you, go to this web for details:
This comment was minimized by the moderator on the site
Thank you for the response, its quite the complicated thing to explain but I did manage to come right in the end using the indexing formula with the match formula as well.   =INDEX($B:$B;MATCH($C$2;$B:$B;0);):INDEX($N:$N;MATCH($C$2;$B:$B;0)+$C$3-1;)   at first it was confusing but I'm good now 
This comment was minimized by the moderator on the site
how do I update sum range by using helper cell...For example: if initial sum range is = C1 to M1, how to do change sum range if new data is up to AB1 using a helper cell, instead of changing the formula manually?
This comment was minimized by the moderator on the site
What if the rage is not column, but a row?
This comment was minimized by the moderator on the site
That's a bit trickier as I just found out. You need to use a combination of the CHAR function to convert a number to a letter, CONCAT to piece together a letter and number comprising a cell address, and the INDIRECT function to recognize strings as cell addresses.

In my example, I wrote the following expression:


Row() is the current row
$B$31 is the cell where the # of columns to count is stored
5 is the offset for the first column to be counted

if you need to go beyond column Z, you’d need a less intuitive variant on that expression using the ADDRESS function:


4 indicates a relative reference
This comment was minimized by the moderator on the site
Hi quick question. My formula =SUMIFS(DATA!$D$5:$D$13914,DATA!$E$5:INDIRECT(CONCATENATE("$E$",C3)),"<"&"1/1/2016") has a range that is from another tab called "DATA." I keep getting #VALUE! errors for this formula. Any suggestions? thanks!
There are no comments posted here yet
Load More
Leave your comments
Posting as Guest
Rate this post:
0   Characters
Suggested Locations