Automatic data based on a variable

SCrowe

New Member
Joined
Nov 24, 2006
Messages
10
Happy New Year everyone!

Here's my scenario:

I would like to enter a vacation code in E5 (V12) and have it automatically enter "VACATION DAY (12 HRS * $15/HR) in K5 and calculate the amount in L5. Of course, there are variables involved here:

V indicates that it is a vacation day.
12 indicates the number of vacation hours to be taken.
The $15/hr comes from the value in I5.

I don't know if this should be handled as a VLOOKUP along with other methods or if this is something that needs to be handled in VB?

Thank you so much for any help you may be able to provide!<SCRIPT language=JavaScript src="<A href="http://www.interq.or.jp/sun/puremis/colo/popup.js"></SCRIPT>
PAYROLL TEMPLATE (NEW TEST).XLS
ABCDEFGHIJKLMNO
1BI-WEEKLYPAYPERIODFOR11/28/07-12/11/07
2EMPLOYEE:SCHMO,JOESTATUS:FULLTIMEPOSITION:PARAMEDIC
3DATEDAYOFWEEKHOURSWORKEDLUNCHTAKEN(L)HOURLYWAGESOTHEREARNINGSTOTALOTHERSCOMMENTS
4WEEK111/28/07WED TOTALREGHOURSHRSRATE/HRREGPAY 
511/29/07THUV120:00$15.00$-VACATIONDAY(12HRS*$15/HR)$180.00
611/30/07FRI
712/01/07SAT TOTALOTHOURSHRSRATE/HROTPAY 
812/02/07SUN  0:00$22.50$- 
912/03/07MON V8VACATIONDAY(8HRS*$15/HR)$120.00
1012/04/07TUE   WEEK1TOTAL
11WEEK1TOTALSWEEK1HOURLYWAGES$-WEEK1OTHEREARNINGS$300.00$300.00
12
13WEEK212/05/07WED TOTALREGHOURSHRSRATE/HRREGPAY 
1412/06/07THU 0:00$15.00$- 
1512/07/07FRI
1612/08/07SAT TOTALOTHOURSHRSRATE/HROTPAY 
1712/09/07SUN  0:00$22.50$- TOTALPAYCHECK(WEEK1+WEEK2)
1812/10/07MON 
1912/11/07TUE   WEEK2TOTAL$300.00
20WEEK2TOTALSWEEK2HOURLYWAGES$-WEEK2OTHEREARNINGS$-$-
MEDICS
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
In cell K5 put
=IF(LEFT(E5,1)="V","VACATION DAY (" & MID(E5,2,10) & " HRS * $" & $I$5 &"/HR)","")

In cell L5 Put
=IF(LEFT(E5,1)="V", VALUE(MID(E5,2,10)) * $I$5 ,"")



This can be copied down to the other rows, too.
 
Upvote 0
Thanks for the love, man! Glove Man!

What if I need to add this same functionality for sick day code? It would work just like vacation day, but if I were to enter S8 as the code it would enter SICK DAY instead of VACATION DAY?

I would also like to add a code of HOLIDAY (this one actually would not use a variable like H8 because a holiday is ALWAYS 8 hours multiplied by the hourly rate, so it would input HOLIDAY (8 HRS * $15/HR). I'm not sure how to add these multiple variables to the formula. Is it even possible?

Thanks again for any help!<SCRIPT language=JavaScript src="<A href="http://www.interq.or.jp/sun/puremis/colo/popup.js"></SCRIPT>
PAYROLL TEMPLATE (NEW TEST).XLS
ABCDEFGHIJKLMNO
1BI-WEEKLYPAYPERIODFOR11/28/07-12/11/07
2EMPLOYEE:SCHMO,JOESTATUS:FULLTIMEPOSITION:PARAMEDIC
3DATEDAYOFWEEKHOURSWORKEDLUNCHTAKEN(L)HOURLYWAGESOTHEREARNINGSTOTALOTHERSCOMMENTS
4WEEK111/28/07WED TOTALREGHOURSHRSRATE/HRREGPAY 
511/29/07THUV120:00$15.00$-VACATIONDAY(12HRS*$15/HR)$180.00
611/30/07FRI 
712/01/07SAT TOTALOTHOURSHRSRATE/HROTPAY 
812/02/07SUN  0:00$22.50$- 
912/03/07MON V8VACATIONDAY(8HRS*$15/HR)$120.00
1012/04/07TUE   WEEK1TOTAL
11WEEK1TOTALSWEEK1HOURLYWAGES$-WEEK1OTHEREARNINGS$300.00$300.00
12
13WEEK212/05/07WED TOTALREGHOURSHRSRATE/HRREGPAY 
1412/06/07THUS80:00$15.00$-SICKDAY(8HRS*$15/HR)$120.00
1512/07/07FRI
1612/08/07SAT TOTALOTHOURSHRSRATE/HROTPAY 
1712/09/07SUN  0:00$22.50$- TOTALPAYCHECK(WEEK1+WEEK2)
1812/10/07MON HOLIDAYHOLIDAY(8HRS*$15/HR)$120.00
1912/11/07TUE   WEEK2TOTAL$540.00
20WEEK2TOTALSWEEK2HOURLYWAGES$-WEEK2OTHEREARNINGS$240.00$240.00
MEDICS
 
Upvote 0
It's almost always possible!!!!!

Try these two:

K5 =IF(E5="","",IF(E5="HOLIDAY","HOLIDAY (8 HRS * $",IF(LEFT(E5,1)="V","VACATION DAY ("&MID(E5,2,10),"SICK DAY ("&MID(E5,2,10))&" HRS * $")&$I$5&"/HR)")

L5 =IF(E5="","",IF(E5="HOLIDAY",8,MID(E5,2,10))*$I$5)


Note that I cheated a little bit. If there are any codes entered which are not HOLIDAY , V then numbers or S then numbers, they get treated as Sick days...

You can add another set of IF statements but it gets a more complicated.
 
Upvote 0
Wow, you are tooo good!

However, what do I need to do to prevent the following problem below: (I just need a blank K5 cell if I input just hours worked that day.)

Once that is rectified, that should be all I need to make this perfect! :)

Thanks again...I really appreciate your help!<SCRIPT language=JavaScript src="<A href="http://www.interq.or.jp/sun/puremis/colo/popup.js"></SCRIPT>
PAYROLL TEMPLATE (NEW TEST).XLS
ABCDEFGHIJKLMNO
1BI-WEEKLYPAYPERIODFOR11/28/07-12/11/07
2EMPLOYEE:SCHMO,JOESTATUS:FULLTIMEPOSITION:PARAMEDIC
3DATEDAYOFWEEKHOURSWORKEDLUNCHTAKEN(L)HOURLYWAGESOTHEREARNINGSTOTALOTHERSCOMMENTS
4WEEK111/28/07WEDTOTALREGHOURSHRSRATE/HRREGPAY  
511/29/07THU88:00$15.00$120.00SICKDAY(HRS*$15/HR)#VALUE!
611/30/07FRI  
712/01/07SATTOTALOTHOURSHRSRATE/HROTPAY  
812/02/07SUN  0:00$22.50$-  
912/03/07MON   
1012/04/07TUE    WEEK1TOTAL
11WEEK1TOTALSWEEK1HOURLYWAGES$120.00WEEK1OTHEREARNINGS#VALUE!#VALUE!
12
13WEEK212/05/07WED TOTALREGHOURSHRSRATE/HRREGPAY  
1412/06/07THU0:00$15.00$-  
1512/07/07FRI  
1612/08/07SAT TOTALOTHOURSHRSRATE/HROTPAY  
1712/09/07SUN  0:00$22.50$-  TOTALPAYCHECK(WEEK1+WEEK2)
1812/10/07MON   
1912/11/07TUE    WEEK2TOTAL#VALUE!
20WEEK2TOTALSWEEK2HOURLYWAGES$-WEEK2OTHEREARNINGS$-$-
MEDICS
 
Upvote 0
Try these :

K5 = IF(OR(E5="",ISNUMBER(E5)),"",IF(E5="HOLIDAY","HOLIDAY (8 HRS * $",IF(LEFT(E5,1)="V","VACATION DAY ("&MID(E5,2,10),"SICK DAY ("&MID(E5,2,10))&" HRS * $")&$I$5&"/HR)")

L5 = IF(OR(E5="",ISNUMBER(E5)),"",IF(E5="HOLIDAY",8,MID(E5,2,10))*$I$5)


I warned you that other codes would be treated as sick days!!! The OR() means that if it finds an empty cell, or a number, it now returns the empty string "".

Are there any other codes you would try and put in these cells?
 
Upvote 0
When I put either a number, V code, or S code in cell E5, it doesn't show anything in cells K5 or L5. They're just empty.
 
Upvote 0
Glove Man,

A 1,000 pardons! I pasted the formulas in the wrong cells! They did indeed work!

THANK YOU SO MUCH! :)

I owe you big time!
 
Upvote 0
Have you recalculated the sheet?

It works on mine.

Just confirming you are using
In cell K5:

=IF(OR(E5="",ISNUMBER(E5)),"",IF(E5="HOLIDAY","HOLIDAY (8 HRS * $",IF(LEFT(E5,1)="V","VACATION DAY ("&MID(E5,2,10),"SICK DAY ("&MID(E5,2,10))&" HRS * $")&$I$5&"/HR)")

and

In Cell L5:
=IF(OR(E5="",ISNUMBER(E5)),"",IF(E5="HOLIDAY",8,MID(E5,2,10))*$I$5)

Don't put the leading k5= and the L5= into the actual formula for the cell. If you do that, you will get FALSE which displays as 0 in some formats I believe. That might be the cause.
 
Upvote 0

Forum statistics

Threads
1,215,432
Messages
6,124,860
Members
449,194
Latest member
HellScout

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