#1   Report Post  
Posted to microsoft.public.excel.misc
DG DG is offline
external usenet poster
 
Posts: 46
Default Nested IF statement

Assume I have the following data:

A1 B1 C1 D1 E1 F1
3 5 4 6 1 2

in cell H1 is the number of columns I want to average. It can be a number
from 1 to 6. Assume 3

H1
3

So I have this formula in Cell I1

=IF(H1=1,F1,IF(H1=2,AVERAGE(E1:F1),IF(H1=3,AVERAGE (D1:F1),IF(H1=4,AVERAGE(C1:F1),IF(H1=5,AVERAGE(B1: F1),AVERAGE(A1,F1))))))

Is there an easier way to do this without a nested if? That H1 determines
how many columns to average.

DG


  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,722
Default Nested IF statement

How's this for simplified?
=)

=AVERAGE(OFFSET(F1,0,0,1,-H1))
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"DG" wrote:

Assume I have the following data:

A1 B1 C1 D1 E1 F1
3 5 4 6 1 2

in cell H1 is the number of columns I want to average. It can be a number
from 1 to 6. Assume 3

H1
3

So I have this formula in Cell I1

=IF(H1=1,F1,IF(H1=2,AVERAGE(E1:F1),IF(H1=3,AVERAGE (D1:F1),IF(H1=4,AVERAGE(C1:F1),IF(H1=5,AVERAGE(B1: F1),AVERAGE(A1,F1))))))

Is there an easier way to do this without a nested if? That H1 determines
how many columns to average.

DG



  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default Nested IF statement

One way:

=AVERAGE(OFFSET(F1,,,,-IF(H1="",6,H1)))

--
Biff
Microsoft Excel MVP


"DG" wrote in message
...
Assume I have the following data:

A1 B1 C1 D1 E1 F1
3 5 4 6 1 2

in cell H1 is the number of columns I want to average. It can be a number
from 1 to 6. Assume 3

H1
3

So I have this formula in Cell I1

=IF(H1=1,F1,IF(H1=2,AVERAGE(E1:F1),IF(H1=3,AVERAGE (D1:F1),IF(H1=4,AVERAGE(C1:F1),IF(H1=5,AVERAGE(B1: F1),AVERAGE(A1,F1))))))

Is there an easier way to do this without a nested if? That H1 determines
how many columns to average.

DG



  #4   Report Post  
Posted to microsoft.public.excel.misc
DG DG is offline
external usenet poster
 
Posts: 46
Default Nested IF statement

Thanks, I knew there had to be a better way.


"Luke M" wrote in message
...
How's this for simplified?
=)

=AVERAGE(OFFSET(F1,0,0,1,-H1))
--
Best Regards,

Luke M
*Remember to click "yes" if this post helped you!*


"DG" wrote:

Assume I have the following data:

A1 B1 C1 D1 E1 F1
3 5 4 6 1 2

in cell H1 is the number of columns I want to average. It can be a
number
from 1 to 6. Assume 3

H1
3

So I have this formula in Cell I1

=IF(H1=1,F1,IF(H1=2,AVERAGE(E1:F1),IF(H1=3,AVERAGE (D1:F1),IF(H1=4,AVERAGE(C1:F1),IF(H1=5,AVERAGE(B1: F1),AVERAGE(A1,F1))))))

Is there an easier way to do this without a nested if? That H1
determines
how many columns to average.

DG





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested IF statement not need help wtamustudentmc Excel Discussion (Misc queries) 3 March 7th 09 11:03 PM
If statement nested k11ngy Excel Discussion (Misc queries) 5 October 13th 08 02:38 PM
Nested If Statement Tracey Excel Discussion (Misc queries) 5 September 3rd 08 01:55 PM
Nested IF/AND Statement buffgirl71 Excel Discussion (Misc queries) 5 October 10th 06 01:07 AM
7+ nested if statement? Turi Excel Worksheet Functions 3 December 20th 04 07:55 PM


All times are GMT +1. The time now is 12:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"