VLOOKUP Problems

Lee 1973

New Member
Joined
Jul 24, 2010
Messages
8
Unfortunalty I am unable to upload an example, I shall though try to explain my situation I am using a VLOOKUP formula to determine from the hours worked what breaks will be deducted from the total hours for example 4 hours = 0.25, 5 hours = 0.25, 6 hours = 0.5, 7 hours = 0.75, 8 hours = 1, 9 hours = 1.5 everything is fine when I use a seperate table (A1:B19) A column defining the hours column defining the breaks, I use a seperate table with hour started in column D and hour finished in column E the total hours are calculated in Column F using a simple =SUM(F2-E2)*24, Column G then calculates the given break time from the table earlier explained using =VLOOKUP(F2,$A$2:$B$19,2,0) everthing runs fine up until I get to 6.5 hours and 7 hours I get the #N/A error when in fact the 0.5 should show on the 6.5 and 0.75 on the 7 hours?

I hope that I have explained this well and that someone can help fix this issue, Many Thanks In advance and happy holidays
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
the 0 in your vlookup()...
=VLOOKUP(F2,$A$2:$B$19,2,0)
is looking for an exact match - F2 may not be an exact match, try using 1, instead of 0

Also, you dont need to use SUM here...
=SUM(F2-E2)*24
You can just use =(F2-E2)*24
 
Upvote 0
Thanks Ford, however when I use the =VLOOKUP(F2,$A$2:$B$19,2,1) version the 7 hours worked only calcualtes a 0.5 break not the 0.75 ? Very frustrating...
 
Upvote 0
STARTFINISHHOURS @ WORKALLOCATED BREAKSTOTAL HOURS
6:00 AM10:00 AM40.253.75
6:00 AM10:30 AM4.50.254.25
6:00 AM11:00 AM50.254.75
6:00 AM11:30 AM5.50.255.25
6:00 AM12:00 PM60.55.5
6:00 AM12:30 PM6.50.56
6:00 AM1:00 PM70.56.5
6:00 AM1:30 PM7.50.756.75
6:00 AM2:00 PM817
6:00 AM2:30 PM8.517.5
6:00 AM3:00 PM91.57.5
6:00 AM3:30 PM9.51.58
6:00 AM4:00 PM101.58.5
6:00 AM4:30 PM10.51.59
6:00 AM5:00 PM111.59.5
6:00 AM5:30 PM11.51.510

<colgroup><col span="5"></colgroup><tbody>
</tbody>
 
Upvote 0
Based on your sample data...
A​
B​
C​
D​
E​
1​
STARTFINISHHOURS @ WORKALLOCATED BREAKSTOTAL HOURS
2​
6:00 AM10:00 AM
4:00​
0.25
3:45​
3​
6:00 AM10:30 AM
4:30​
0.25
4:15​
4​
6:00 AM11:00 AM
5:00​
0.25
4:45​
5​
6:00 AM11:30 AM
5:30​
0.25
5:15​
6​
6:00 AM12:00 PM
6:00​
0.05
5:57​
7​
6:00 AM12:30 PM
6:30​
0.05
6:27​
8​
6:00 AM1:00 PM
7:00​
0.05
6:57​
9​
6:00 AM1:30 PM
7:30​
0.75
6:45​
10​
6:00 AM2:00 PM
8:00​
1
7:00​
11​
6:00 AM2:30 PM
8:30​
1
7:30​
12​
6:00 AM3:00 PM
9:00​
1.5
7:30​
13​
6:00 AM3:30 PM
9:30​
1.5
8:00​
14​
6:00 AM4:00 PM
10:00​
1.5
8:30​
15​
6:00 AM4:30 PM
10:30​
1.5
9:00​
16​
6:00 AM5:00 PM
11:00​
1.5
9:30​
17​
6:00 AM5:30 PM
11:30​
1.5
10:00​
18​
19​
20​
4:00​
0.25
21​
5:00​
0.25
22​
6:00​
0.05
23​
7:00​
0.75
24​
8:00​
1.00
25​
9:00​
1.50
C2=B2-A2
D2=VLOOKUP(C2,$A$20:$B$25,2,1)
E2=C2-(D2/24)
all copied down
 
Upvote 0
Thanks Ford, That works really well however I need to be able to have a total number of hours at the end of the week/month as the above being an example the total number of hours should be close to 109.5 hours rather than 13:45 hours is there another little trick to combat this ? I really appreciate your help in this matter
 
Upvote 0
OK, same table, but I added a column for date (your sample did not show any dates?

A​
B​
C​
D​
E​
F​
1​
DateSTARTFINISHHOURS WORKBREAKSTotal
2​
2-Dec​
6:00 AM10:00 AM
4:00
0.25
3:45
3​
2-Dec​
6:00 AM10:30 AM
4:30
0.25
4:15
4​
2-Dec​
6:00 AM11:00 AM
5:00
0.25
4:45
5​
2-Dec​
6:00 AM11:30 AM
5:30
0.25
5:15
6​
2-Dec​
6:00 AM12:00 PM
6:00
0.05
5:57
7​
2-Dec​
6:00 AM12:30 PM
6:30
0.05
6:27
8​
2-Dec​
6:00 AM1:00 PM
7:00
0.05
6:57
9​
3-Dec​
6:00 AM1:30 PM
7:30
0.75
6:45
10​
3-Dec​
6:00 AM2:00 PM
8:00
1
7:00
11​
3-Dec​
6:00 AM2:30 PM
8:30
1
7:30
12​
3-Dec​
6:00 AM3:00 PM
9:00
1.5
7:30
13​
3-Dec​
6:00 AM3:30 PM
9:30
1.5
8:00
14​
4-Dec​
6:00 AM4:00 PM
10:00
1.5
8:30
15​
4-Dec​
6:00 AM4:30 PM
10:30
1.5
9:00
16​
4-Dec​
6:00 AM5:00 PM
11:00
1.5
9:30
17​
4-Dec​
6:00 AM5:30 PM
11:30
1.5
10:00
18​
19​
20​
4:00
0.252-Dec
37:21:00
21​
5:00
0.253-Dec
36:45:00
22​
6:00
0.054-Dec
37:00:00
23​
7:00
0.75Week
111:06:00
24​
8:00
1
25​
9:00
1.5

E20=SUMIF($A$2:$A$17,D20,$F$2:$F$17)
copied down. This will give you a total for a specific date

E23=SUMIFS($F$2:$F$17,$A$2:$A$17,">="&D20,$A$2:$A$17,"<="&$D$22)
This will give you a total between those 2 dates...you could put a different start and end date in different cells, to make this more dynamic
In the above (new) formulas, format them to Custom [h]:mm:ss
 
Upvote 0
Thank You Martin, I did use your suggestion plus I also used another way of doing which now works brilliantly, let me again thank you very much I wouldn't have gotten there without your valuable information

Thanks

How do I mark this thread as solved?
 
Upvote 0

Forum statistics

Threads
1,214,789
Messages
6,121,593
Members
449,038
Latest member
Arbind kumar

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