Assign integer value to a string of characters(a word)

Guanjin Peter

Active Member
Joined
May 21, 2008
Messages
429
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

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
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.
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,941
Members
449,094
Latest member
teemeren

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