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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
That simply clears the cell, I want it to do literally nothing. If something is in that cell, I want it to remain there.
 
Upvote 0
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") ?
 
Upvote 0
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
 
Upvote 0
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?
 
Upvote 0
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.
 
Upvote 0
The macro I gave you was copied from my VBE. It ran fine. Double check everything or paste the code you used.
 
Upvote 0

Forum statistics

Threads
1,214,424
Messages
6,119,404
Members
448,893
Latest member
AtariBaby

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