#### Guanjin Peter

##### Active Member
let's say cell a1 contains either the word: Leave OR HalfDay

cell b2 takes the value from a1 and divide by 2. ----------- b2=(a1/2)
can I assign
leave=1
halfDay=0.5

so if a1 contains the word leave, b2 will be 0.5
if a1 contains the word Half-day, b2 will be 0.25

### Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.

#### mikerickson

##### MrExcel MVP
A double IF should work
=IF(A1="leave",.5,IF(A1="Half-day",.25,"other word"))

#### hkaplan2

##### Active Member
If you have many categories (i.e Leave, HalfDay, Sick, Vacation, etc) then I would use vlookup. Create a table like below:

Column1 Column2
Leave .5
HalfDay .25
Sick 1
Vacation 1

Highlight the table and name the range (i.e. leavetable).

Then use the formula =vlookup(A1,leavetable,2). If you only have a few names, then nested If works fine, but gets confusing when you try to nest several if statements.

#### Guanjin Peter

##### Active Member
w0w thanks. #2 is sure an interesting solution...

Replies
2
Views
234
Replies
15
Views
858
Replies
2
Views
383
Replies
0
Views
135
Replies
1
Views
438

1,190,959
Messages
5,983,863
Members
439,867
Latest member

### 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.

### Which adblocker are you using?

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

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