if function

Copper Contributor

I am a fairly new excel user and on my spread sheet I am wanting it to put a mileage number in a column if the name of the business in another column is something.  I am doing a spread sheet where i am tracking miles traveled.  When I type in Home Depot for example I would like my column m-mileage to come up with 2.  How do I do that?

 

1 Reply

@danielle1962 

With IF formula you can apply this formula in the attached example:

=IF(A2="Home Depot",2,IF(A2="Away Depot",3,IF(A2="Home Port",4,"")))

If you work with Office365 or 2021 you can use IFS or XLOOKUP as well.

 

In the attached file there is this formula in cell C2 copied down to C4:

=VLOOKUP(A2,$G$2:$H$4,2,FALSE)

And there is this formula in cell D2 copied down to D4:

=INDEX($H$2:$H$4,MATCH(A2,$G$2:$G$4,0))

Both formulas work with the help of the data in range G2:H4.