How to define range based on another cell value in Excel?
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.
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.
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))).
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!
|Kutools for Excel: with more than 300 handy Excel add-ins, free to try with no limitation in 30 days.|