If statments, PLEASE HELP

imported_unknown

Active Member
Joined
Jan 13, 2002
Messages
424
Is it possible for me to set an IF statement to do nothing if a criteria is not met. For example:

my IF statement in the D column is

IF(A:A = "dog", "bark")

I want to be able to do this without affecting the D column for records that do not currently have "dog" in the A column, right now, what happens is if the records don't have "dog" in the A column FALSE is entered in the D column.
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

imported_unknown

Active Member
Joined
Jan 13, 2002
Messages
424
That simply clears the cell, I want it to do literally nothing. If something is in that cell, I want it to remain there.
 

Aladin Akyurek

MrExcel MVP
Joined
Feb 14, 2002
Messages
85,209
On 2002-10-04 16:47, xcelarator wrote:
That simply clears the cell, I want it to do literally nothing. If something is in that cell, I want it to remain there.

Entering a formula in a cell, say, D10, wipes out the previous value in D10.

Why

IF(A:A = "dog", "bark")

instead of

IF(A1 = "dog", "bark") ?
 

Juan Pablo González

MrExcel MVP
Joined
Feb 8, 2002
Messages
11,959

ADVERTISEMENT

Maybe use a circular reference instead ?

In D10 use

=IF(A1="dog","bark",D10)
 

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
You will need to use code. Something like:

Sub Fixit()
Dim cel As Range
Dim myVar As Range
Set myVar = Selection
For Each cel In myVar
If cel.Value = "dog" Then cel.Offset(0, 1).Value = "bark"
Next

End Sub

Select the cells in column A and run the macro
 

imported_unknown

Active Member
Joined
Jan 13, 2002
Messages
424

ADVERTISEMENT

Thank you for your help. How do I make sure in the macro that it will input the value "bark" into the c or d column, which ever i decide to use?
 

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
The second argument of the Offset Function indicates how many columns to move over to insert the data. So for column C, change the 1 to a 2, For column D, Change it to 3, etc.
 

lenze

Legend
Joined
Feb 18, 2002
Messages
13,690
The macro I gave you was copied from my VBE. It ran fine. Double check everything or paste the code you used.
 

Forum statistics

Threads
1,144,362
Messages
5,723,909
Members
422,527
Latest member
JayTheKaz

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