Need formula to sum cells

NightKnight

New Member
Joined
Sep 11, 2011
Messages
17
Office Version
  1. 2019
Platform
  1. MacOS
It looks to me like an easy one, but I had spent hours trying to find the answer:
In range A1:A5 I have values.
I can enter a value only in B1 OR B2.
I need in C1 a formula that will tell: If B1 and B2 are empty, do nothing; if not, take the value from B1 or B2 and add it to the sum of A1:A5.
Thanks in advance.
NK
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
It looks to me like an easy one, but I had spent hours trying to find the answer:
In range A1:A5 I have values.
I can enter a value only in B1 OR B2.
I need in C1 a formula that will tell: If B1 and B2 are empty, do nothing; if not, take the value from B1 or B2 and add it to the sum of A1:A5.
Thanks in advance.
NK
I interpret that highlighted statement to mean that only one of the cells, if any, will contain an entry.

=IF(B1&B2="","",SUM(A1:A5,B1:B2))
 
Upvote 0
It looks to me like an easy one, but I had spent hours trying to find the answer:
In range A1:A5 I have values.
I can enter a value only in B1 OR B2.
I need in C1 a formula that will tell: If B1 and B2 are empty, do nothing; if not, take the value from B1 or B2 and add it to the sum of A1:A5.
Thanks in advance.
NK
If both B1 and B2 have a value, what would be the desired action.

If just B1 or B2 a value or none has a value:

=SUM(A1:A5,B1:B2)

would also suffice.
 
Upvote 0
Thank you T. Valko and VoG. I appreciate your answers. Both of them work (of course!) :)
(It's so easy to do things when you know WHAT to do).... :)
 
Upvote 0
Sorry Aladin. Didn't see your reply when I previously posted.
With yours I have a problem that when B1 and B2 are empty I get the sum of A1:A5 and I want C1 empty if B1 and B2 are empty.
Thanks anyway.
 
Upvote 0
Sorry Aladin. Didn't see your reply when I previously posted.
With yours I have a problem that when B1 and B2 are empty I get the sum of A1:A5 and I want C1 empty if B1 and B2 are empty.
Thanks anyway.

Right. How about some caution...

=IF(COUNT(B1:B2)=1,SUM(A1:A5,B1:B2),"")

in case both B1 and B2 have values?
 
Upvote 0
Well... feedback is almost the only way of showing appreciation, isn't it? ;)
Aladin, thanks for the "fix"... now it's OK! :)
Have a good coming week guys!
 
Upvote 0

Forum statistics

Threads
1,224,607
Messages
6,179,871
Members
452,948
Latest member
UsmanAli786

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