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

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
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,214,628
Messages
6,120,618
Members
448,973
Latest member
ChristineC

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