How to do a specific excel sum only when certain cells are filled

Debjanes

New Member
Joined
Sep 21, 2018
Messages
2
Hi all. Wondering if anyone can help me? I know how to do basic sums in excel but having trouble with one specifically and google doesn't seem to help.

For example I want a sum that does the following in H2
=sum(G2-A2)

HOWEVER I only want it to give me a value when there is a value in the G2 box. Both G2 A2 are dates and i want to know the number of days between those two dates. So if i set the answer box to number rather than date it works if there is a value in G2. If there isn't a date in G2 it gives me a massive minus figure as it is trying to take a date from a blank. Hope that makes sense? I only want the calculation in each H row to have a figure in if the G column isn't blank.

Would really appreciate your help as it would make my day so much easier.
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Thank you. Is there anyway to not have '0's in the boxes where there was no value in the matching part though? As this messes up my average sums at the bottom of that column. Could do with there being nothing in those cells instead of a ). Sorry to be a pain. Thank you so much for helping.
 
Upvote 0

Forum statistics

Threads
1,214,827
Messages
6,121,818
Members
449,049
Latest member
cybersurfer5000

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