IF Formula

G

Guest

I need help with the formula.

A B C D E
1 Jan Feb Mar Apr May
2 10 5 15 7 8

If K2 is Mar I need to sum A2 thru C2. If K2 is May I need to sum A2 thru E2.

Thank you in advance.
 
G

Guest

If the only possible options are Mar and May then:

=IF(K2="Mar",SUM(A2:AC2),SUM(A2:E2))

If K2 can have any month, then you would need something with the MATCH
function
 
G

Guest

=SUM(A2:INDIRECT(ADDRESS(2,MATCH(K2,A1:E1,0),4,1)))
If you have all months, adjust ranges!

Regards,
Stefi

„Lisa†ezt írta:
 
W

Wondering

This formula returns an empty cell if K2 is not Mar or May. If you want it
to return 0, change the "" to 0

=IF(K2="Mar", SUM(A2:C2),if(K2="May",SUM(A2:E2),""))
 
G

Guest

That worked! Thank you Stefi.

Stefi said:
=SUM(A2:INDIRECT(ADDRESS(2,MATCH(K2,A1:E1,0),4,1)))
If you have all months, adjust ranges!

Regards,
Stefi

„Lisa†ezt írta:
 
G

Guest

This one worked. That you!

Don Guillett said:
=SUM(A2:OFFSET(A2,0,MATCH(k2,1:1,0)-1))


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

FORMULA 2
Excel Help with dates 2
if formula 4
Lookup, index, match, range, oh my... 1
Return the value of a column heading 1
Formula to calculate the data of the last order 1
Count a cell in month format 5
Lookup 4

Top