Variable # Cols Used for Avg & Range Calculation

rwmill9716

Active Member
Joined
May 20, 2006
Messages
495
Office Version
  1. 2013
Platform
  1. Windows
I need formula for Cols A & B that allow me to specify in cell F4 the number of columns that are to be used in the row calculation of average (col A) and Range (Col B as Max() - Min()). That is, I want to be able to change cell F4 from 2 to 20 and get the appropriate row averages in Cols A and B. For example, Cell A7 when F4=5 would calculate: Average(C7:G7); and Cell B7 would calculate: Max(C7:G7)-Min(C7:G7).

Thanks,

ric

<b>Excel 2003</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th><th>G</th><th>H</th><th>I</th><th>J</th><th>K</th><th>L</th><th>M</th><th>N</th><th>O</th><th>P</th><th>Q</th><th>R</th><th>S</th><th>T</th><th>U</th><th>V</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="font-weight: bold;text-align: center;;"></td><td style="font-weight: bold;text-align: center;;"></td><td style="font-weight: bold;text-align: center;border-right: 1px solid black;;">n =</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #00FF00;;">5</td><td style="font-weight: bold;text-align: center;border-left: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;;"></td><td style="font-weight: bold;text-align: center;;"></td><td style="font-weight: bold;text-align: center;;"></td><td style="font-weight: bold;text-align: center;;"></td><td style="font-weight: bold;text-align: center;;"></td><td style="font-weight: bold;text-align: center;;"></td><td style="font-weight: bold;text-align: center;;"></td><td style="font-weight: bold;text-align: center;;"></td><td style="font-weight: bold;text-align: center;;"></td><td style="font-weight: bold;text-align: center;;"></td><td style="font-weight: bold;text-align: center;;"></td><td style="font-weight: bold;text-align: center;;"></td><td style="font-weight: bold;text-align: center;;"></td><td style="font-weight: bold;text-align: center;;"></td><td style="font-weight: bold;text-align: center;;"></td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="text-align: right;border-bottom: 1px solid black;;"></td><td style="text-align: right;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td><td style="font-weight: bold;text-align: center;border-bottom: 1px solid black;;"></td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #C0C0C0;;">StDev</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">Range</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #C0C0C0;;">1</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">2</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">3</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">4</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">5</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">6</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">7</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">8</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">9</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">10</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">11</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">12</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">13</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">14</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">15</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">16</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">17</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">18</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">19</td><td style="font-weight: bold;text-align: center;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;background-color: #C0C0C0;;">20</td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="text-align: center;border-top: 1px solid black;;">4.1</td><td style="text-align: center;border-top: 1px solid black;;">9.6</td><td style="text-align: center;border-top: 1px solid black;;">37.3</td><td style="text-align: center;border-top: 1px solid black;;">37.4</td><td style="text-align: center;border-top: 1px solid black;;">34.8</td><td style="text-align: center;border-top: 1px solid black;;">43.1</td><td style="text-align: center;border-top: 1px solid black;;">44.4</td><td style="text-align: center;border-top: 1px solid black;;">46.6</td><td style="text-align: center;border-top: 1px solid black;;">45.5</td><td style="text-align: center;border-top: 1px solid black;;">34.4</td><td style="text-align: center;border-top: 1px solid black;;">34.8</td><td style="text-align: center;border-top: 1px solid black;;">35.6</td><td style="text-align: center;border-top: 1px solid black;;">38.2</td><td style="text-align: center;border-top: 1px solid black;;">37.9</td><td style="text-align: center;border-top: 1px solid black;;">40.3</td><td style="text-align: center;border-top: 1px solid black;;">42.2</td><td style="text-align: center;border-top: 1px solid black;;">33.1</td><td style="text-align: center;border-top: 1px solid black;;">41.2</td><td style="text-align: center;border-top: 1px solid black;;">39.5</td><td style="text-align: center;border-top: 1px solid black;;">39.6</td><td style="text-align: center;border-top: 1px solid black;;">39.8</td><td style="text-align: center;border-top: 1px solid black;;">37.3</td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style="text-align: center;;">3.0</td><td style="text-align: center;;">7.4</td><td style="text-align: center;;">42.9</td><td style="text-align: center;;">41.5</td><td style="text-align: center;;">42.4</td><td style="text-align: center;;">42</td><td style="text-align: center;;">35.6</td><td style="text-align: center;;">36</td><td style="text-align: center;;">40.8</td><td style="text-align: center;;">46.1</td><td style="text-align: center;;">40.5</td><td style="text-align: center;;">41.7</td><td style="text-align: center;;">38.8</td><td style="text-align: center;;">38.5</td><td style="text-align: center;;">40.2</td><td style="text-align: center;;">40.6</td><td style="text-align: center;;">37.1</td><td style="text-align: center;;">41.5</td><td style="text-align: center;;">44.7</td><td style="text-align: center;;">41.5</td><td style="text-align: center;;">46.2</td><td style="text-align: center;;">44.5</td></tr><tr ><td style="color: #161120;text-align: center;">9</td><td style="text-align: center;;">3.7</td><td style="text-align: center;;">9.0</td><td style="text-align: center;;">39.6</td><td style="text-align: center;;">39.2</td><td style="text-align: center;;">30.7</td><td style="text-align: center;;">37</td><td style="text-align: center;;">38.4</td><td style="text-align: center;;">42.3</td><td style="text-align: center;;">36.3</td><td style="text-align: center;;">41.7</td><td style="text-align: center;;">42.8</td><td style="text-align: center;;">35.1</td><td style="text-align: center;;">40.1</td><td style="text-align: center;;">41.6</td><td style="text-align: center;;">41.7</td><td style="text-align: center;;">40.2</td><td style="text-align: center;;">39.4</td><td style="text-align: center;;">36.9</td><td style="text-align: center;;">37.9</td><td style="text-align: center;;">38.8</td><td style="text-align: center;;">39.4</td><td style="text-align: center;;">42.6</td></tr><tr ><td style="color: #161120;text-align: center;">10</td><td style="text-align: center;;">3.2</td><td style="text-align: center;;">8.0</td><td style="text-align: center;;">39.4</td><td style="text-align: center;;">36.8</td><td style="text-align: center;;">44.5</td><td style="text-align: center;;">38.6</td><td style="text-align: center;;">36.5</td><td style="text-align: center;;">47.4</td><td style="text-align: center;;">39.7</td><td style="text-align: center;;">38.6</td><td style="text-align: center;;">41.5</td><td style="text-align: center;;">36.9</td><td style="text-align: center;;">39.7</td><td style="text-align: center;;">35.4</td><td style="text-align: center;;">41.1</td><td style="text-align: center;;">39.7</td><td style="text-align: center;;">39.4</td><td style="text-align: center;;">39.5</td><td style="text-align: center;;">37.8</td><td style="text-align: center;;">38.9</td><td style="text-align: center;;">34.8</td><td style="text-align: center;;">41</td></tr><tr ><td style="color: #161120;text-align: center;">11</td><td style="text-align: center;;">2.4</td><td style="text-align: center;;">6.7</td><td style="text-align: center;;">43.4</td><td style="text-align: center;;">36.7</td><td style="text-align: center;;">39</td><td style="text-align: center;;">38.9</td><td style="text-align: center;;">38.7</td><td style="text-align: center;;">44</td><td style="text-align: center;;">37.3</td><td style="text-align: center;;">38.3</td><td style="text-align: center;;">40.7</td><td style="text-align: center;;">36.4</td><td style="text-align: center;;">42.5</td><td style="text-align: center;;">37</td><td style="text-align: center;;">39.8</td><td style="text-align: center;;">39.9</td><td style="text-align: center;;">31.9</td><td style="text-align: center;;">42.7</td><td style="text-align: center;;">39</td><td style="text-align: center;;">38.2</td><td style="text-align: center;;">44.7</td><td style="text-align: center;;">43</td></tr><tr ><td style="color: #161120;text-align: center;">12</td><td style="text-align: center;;">2.5</td><td style="text-align: center;;">6.4</td><td style="text-align: center;;">41.8</td><td style="text-align: center;;">36.5</td><td style="text-align: center;;">42.8</td><td style="text-align: center;;">39.2</td><td style="text-align: center;;">39.8</td><td style="text-align: center;;">41.8</td><td style="text-align: center;;">41.7</td><td style="text-align: center;;">40.4</td><td style="text-align: center;;">43.2</td><td style="text-align: center;;">36.3</td><td style="text-align: center;;">46</td><td style="text-align: center;;">42.6</td><td style="text-align: center;;">37.9</td><td style="text-align: center;;">38.8</td><td style="text-align: center;;">40.8</td><td style="text-align: center;;">41.2</td><td style="text-align: center;;">39.8</td><td style="text-align: center;;">42.2</td><td style="text-align: center;;">37.2</td><td style="text-align: center;;">36.7</td></tr><tr ><td style="color: #161120;text-align: center;">13</td><td style="text-align: center;;">1.9</td><td style="text-align: center;;">5.2</td><td style="text-align: center;;">40</td><td style="text-align: center;;">40.4</td><td style="text-align: center;;">37.9</td><td style="text-align: center;;">43.1</td><td style="text-align: center;;">39.7</td><td style="text-align: center;;">41.9</td><td style="text-align: center;;">37.6</td><td style="text-align: center;;">37.7</td><td style="text-align: center;;">40.5</td><td style="text-align: center;;">39.4</td><td style="text-align: center;;">45.5</td><td style="text-align: center;;">42.8</td><td style="text-align: center;;">40.4</td><td style="text-align: center;;">43.1</td><td style="text-align: center;;">42.7</td><td style="text-align: center;;">39.2</td><td style="text-align: center;;">41.6</td><td style="text-align: center;;">42.2</td><td style="text-align: center;;">36.8</td><td style="text-align: center;;">39</td></tr><tr ><td style="color: #161120;text-align: center;">14</td><td style="text-align: center;;">2.6</td><td style="text-align: center;;">6.0</td><td style="text-align: center;;">44</td><td style="text-align: center;;">42.8</td><td style="text-align: center;;">39.2</td><td style="text-align: center;;">38.9</td><td style="text-align: center;;">38.1</td><td style="text-align: center;;">36.6</td><td style="text-align: center;;">40.9</td><td style="text-align: center;;">36</td><td style="text-align: center;;">41.3</td><td style="text-align: center;;">41.6</td><td style="text-align: center;;">41.7</td><td style="text-align: center;;">44.2</td><td style="text-align: center;;">39.7</td><td style="text-align: center;;">37.8</td><td style="text-align: center;;">37.2</td><td style="text-align: center;;">39.1</td><td style="text-align: center;;">31.9</td><td style="text-align: center;;">40</td><td style="text-align: center;;">43.5</td><td style="text-align: center;;">40.2</td></tr><tr ><td style="color: #161120;text-align: center;">15</td><td style="text-align: center;;">1.6</td><td style="text-align: center;;">3.8</td><td style="text-align: center;;">38.4</td><td style="text-align: center;;">38.1</td><td style="text-align: center;;">40.3</td><td style="text-align: center;;">41.9</td><td style="text-align: center;;">39</td><td style="text-align: center;;">41.3</td><td style="text-align: center;;">37.9</td><td style="text-align: center;;">40.2</td><td style="text-align: center;;">37</td><td style="text-align: center;;">36.1</td><td style="text-align: center;;">40.9</td><td style="text-align: center;;">34</td><td style="text-align: center;;">40.9</td><td style="text-align: center;;">43.1</td><td style="text-align: center;;">37.7</td><td style="text-align: center;;">40.7</td><td style="text-align: center;;">39.7</td><td style="text-align: center;;">37.3</td><td style="text-align: center;;">38.4</td><td style="text-align: center;;">43.9</td></tr><tr ><td style="color: #161120;text-align: center;">16</td><td style="text-align: center;;">3.2</td><td style="text-align: center;;">7.2</td><td style="text-align: center;;">43.2</td><td style="text-align: center;;">42.1</td><td style="text-align: center;;">38.2</td><td style="text-align: center;;">37.1</td><td style="text-align: center;;">35.9</td><td style="text-align: center;;">38</td><td style="text-align: center;;">42.3</td><td style="text-align: center;;">41.8</td><td style="text-align: center;;">43</td><td style="text-align: center;;">39.3</td><td style="text-align: center;;">38.2</td><td style="text-align: center;;">36.9</td><td style="text-align: center;;">39.6</td><td style="text-align: center;;">40.5</td><td style="text-align: center;;">38.2</td><td style="text-align: center;;">36.8</td><td style="text-align: center;;">40.3</td><td style="text-align: center;;">44.6</td><td style="text-align: center;;">38.1</td><td style="text-align: center;;">33.3</td></tr><tr ><td style="color: #161120;text-align: center;">17</td><td style="text-align: center;;">3.6</td><td style="text-align: center;;">8.4</td><td style="text-align: center;;">37.2</td><td style="text-align: center;;">45.5</td><td style="text-align: center;;">40.1</td><td style="text-align: center;;">37.1</td><td style="text-align: center;;">42.2</td><td style="text-align: center;;">37</td><td style="text-align: center;;">32.5</td><td style="text-align: center;;">43.2</td><td style="text-align: center;;">42.5</td><td style="text-align: center;;">38.5</td><td style="text-align: center;;">35.5</td><td style="text-align: center;;">41.3</td><td style="text-align: center;;">40.5</td><td style="text-align: center;;">37.8</td><td style="text-align: center;;">43.1</td><td style="text-align: center;;">38.4</td><td style="text-align: center;;">40.1</td><td style="text-align: center;;">39.5</td><td style="text-align: center;;">42.8</td><td style="text-align: center;;">42.5</td></tr><tr ><td style="color: #161120;text-align: center;">18</td><td style="text-align: center;;">3.3</td><td style="text-align: center;;">8.3</td><td style="text-align: center;;">35.2</td><td style="text-align: center;;">39.4</td><td style="text-align: center;;">42.9</td><td style="text-align: center;;">43.5</td><td style="text-align: center;;">41</td><td style="text-align: center;;">38.7</td><td style="text-align: center;;">42.4</td><td style="text-align: center;;">43</td><td style="text-align: center;;">41.8</td><td style="text-align: center;;">32.8</td><td style="text-align: center;;">44</td><td style="text-align: center;;">37.4</td><td style="text-align: center;;">43</td><td style="text-align: center;;">38.9</td><td style="text-align: center;;">41.3</td><td style="text-align: center;;">39.6</td><td style="text-align: center;;">41.5</td><td style="text-align: center;;">39.1</td><td style="text-align: center;;">41.8</td><td style="text-align: center;;">39.6</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet1</p><br /><br />
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Try these array formulas entered with CTRL + SHIFT + ENTER

A7: =AVERAGE(IF(C$6:V$6<=$F$4,C7:V7))
B7: =MAX(IF(C$6:V$6<=$F$4,C7:V7))-MIN(IF(C$6:V$6<=$F$4,C7:V7))
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,334
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top