user2062360
user2062360

Reputation: 1523

Excel if statement with string comparison

How do I give an if statement in excel when we want to compare with a string?

I tried something like this:

=IF(B2="mystring", 595, B2)

Here basically, I am trying to replace a particular string in all the cells of a column with the number 595.

Upvotes: 0

Views: 3770

Answers (3)

PA.
PA.

Reputation: 29339

Err 522 means you have a circular reference. You cannot refer in a formula to the same cell the formula sits in.

Yoy need to create a new column for the formula.

So, if you want to change values in column B

  • create a new colum C
  • in C2 put your formula =IF(B2="mystring",333,B2) there
  • copy your formula to all cells in column C
  • select your new column C
  • copy
  • paste special | values into column B

Upvotes: 2

Omar Sedki
Omar Sedki

Reputation: 608

IF(EXACT(B2,"mystring")=true,592,B2)

Upvotes: 1

Trebor
Trebor

Reputation: 813

Try IIF(b2="my string", 595,b2)

Upvotes: -1

Related Questions