If Statement - replacing two cells

techgirl

Board Regular
Joined
Sep 16, 2002
Messages
168
I need to know how to use an If statement for the following scenario...
If A1 = 0, the replace the entries in C1 and E1 with 0.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
58,415
Office Version
  1. 365
Platform
  1. Windows
Here is the section of VBA code to do that.
Code:
If Range("A1")=0 Then
    Range("C1")=0
    Range("E1")=0
End If
 

Scott Huish

MrExcel MVP
Joined
Mar 17, 2004
Messages
19,958
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
A formula can not replace the contents of other cells.
If there are formulas in C1 and E1, you can incorporate this into the formula. If so, please post these formulas, if not you will need VBA.
 

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
58,415
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

You cannot store both a value and a cell in the same cell in Excel, and Excel formulas can only update values in the cells they are found in (they cannot update other cells directly).

So you either need to use VBA, or re-think how you want to do this.
 

daniels012

Well-known Member
Joined
Jan 13, 2005
Messages
5,219
You would have to have in Cells C1 and E1 a formula!
Like in cell C1:
=IF(A1=0,0,other condition)

Michael
 

orbea_adam

Well-known Member
Joined
Nov 15, 2005
Messages
500

ADVERTISEMENT

I need to know how to use an If statement for the following scenario...
If A1 = 0, the replace the entries in C1 and E1 with 0.
Do C1 and E1 have formulas already? If so, then: =IF(A1=0,0,your current formula)
If C1 and E1 and hard-typed entries, then I agree with the others
 

techgirl

Board Regular
Joined
Sep 16, 2002
Messages
168
C1 and E1 had nothing in them. I have added the following in each cell and worked great.

C1 =IF(A1=0,0,A1*B1)
E1 =IF(C1=0,0,C1+D1)

Thanks so much!
 

Forum statistics

Threads
1,137,301
Messages
5,680,705
Members
419,929
Latest member
Atlas Quinn

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