if, then, do nothing?

merlin777

Well-known Member
Joined
Aug 29, 2009
Messages
1,397
Office Version
  1. 2007
IF statements are 'IF X is true, do Y, else do Z'.

Is there a statement that does 'IF X is true, do Y, else do nothing?

I'm basically looking for an IF statement that leaves the existing value unchanged if a condition is not true.

any thoughts?
 
that's it!

now can i do that with a formula or do i have to dust off my rather limited vba?
 
Upvote 0
are you talking about doing this in a particular cell and updating that particular cell. If so, then the only way that can be done is with VBA if no, then you can use a function like this:

Code:
=If(A1=[condition], [change],A1)
where you would have to set [condition] and [change]

if you want the same cell to be adjusted then
Code:
 If Range(A1) = [condition] then Range(A1)=[change]
would do
 
Upvote 0
thanks, brian - i'll give those a try.

vog - thanks for the suggestion but the cell would still be changed to "" if the condition was untrue and i want to keep the existing value.
 
Upvote 0
brian, is the second statement vba? I can't get anything like that to work in a cell.
 
Upvote 0
Yes the 2nd statement is VBA. As I mentioned there is no input you can make in a cell that will update a different cell without using VBA.
 
Upvote 0
are you talking about doing this in a particular cell and updating that particular cell. If so, then the only way that can be done is with VBA if no, then you can use a function like this:

Code:
=If(A1=[condition], [change],A1)
where you would have to set [condition] and [change]

if you want the same cell to be adjusted then
Code:
 If Range(A1) = [condition] then Range(A1)=[change]
would do
wow that is terrible, sorry, the 2nd statement should be
Code:
 If Range("A1") = [condition] then Range("A1")=[change]
 
Upvote 0

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