if no value equal 0 if change equals change amount

agoodson1956

Board Regular
Joined
Sep 1, 2016
Messages
140
I have a cell A2 with a number in it. Then I have another cell D2 with a number in it.

I want to subtract A2 from D2 and update cell G2, but if the value in D2 is blank I want G2 value to be 0

Help please
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

SQUIDD

Well-known Member
Joined
Jan 2, 2009
Messages
1,998
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows
try this in g2
Code:
=IF(D2="","0",D2-A2)

dave
 

Canapone

Active Member
Joined
May 10, 2007
Messages
463
Hi,

in G2

--IF(D2,D2-A2)

Regards

----------

Hi Squidd, sorry: did not mean to overlap.
 
Last edited:

Tetra201

MrExcel MVP
Joined
Oct 14, 2016
Messages
3,747
Just to note:

SQUIDD's formula will return "0" as text, not as a number.
Canapone's formula will not work if cell D2 is blank-looking (not actually empty).

The following formula addresses both issues:

=IF(D2="",,D2-A2)
 

SQUIDD

Well-known Member
Joined
Jan 2, 2009
Messages
1,998
Office Version
  1. 2019
  2. 2016
Platform
  1. Windows

ADVERTISEMENT

Hi

if value 0 is required you may also change my formula to

Code:
=IF(D2="",0,D2-A2)

dave
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,484
Messages
5,837,602
Members
430,505
Latest member
DevAlex

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
Top