Vlookup Question

UKFoolsGold

New Member
Joined
Jan 31, 2019
Messages
5
Hi All,

I hope someone can help me to save my sanity!

I have created a spreadsheet which is basically a shut plan,from the shut plan a Gantt chart is created using conditional formatting.


Because the shut plan needs to be hourly over a 3-week span,the Gantt chart was tricky for me (I’m pretty average on excel).
The start/finish times of jobs are in dd/mm/yyyy hh:hhformat as they are extracted from an asset management system and that is theformat they are in when they are extracted.
The way I thought I could get the Gantt chart working overindividual day/hours for 3 weeks was to assign each hour a unique number. Example below:
<tbody> [TD="width: 130, bgcolor: transparent"]
Date
[/TD]
[TD="width: 85, bgcolor: transparent"] Reference [/TD]
[TD="width: 130, bgcolor: transparent"]
01/02/2019 00:00
[/TD]
[TD="width: 85, bgcolor: transparent"]
1
[/TD]
[TD="width: 130, bgcolor: transparent"]
01/02/2019 01:00
[/TD]
[TD="width: 85, bgcolor: transparent"]
2
[/TD]
[TD="width: 130, bgcolor: transparent"]
01/02/2019 02:00
[/TD]
[TD="width: 85, bgcolor: transparent"]
3
[/TD]
[TD="width: 130, bgcolor: transparent"]
01/02/2019 03:00
[/TD]
[TD="width: 85, bgcolor: transparent"]
4
[/TD]
[TD="width: 215, bgcolor: transparent, colspan: 2"]
And so on…
[/TD]
</tbody>

This reference data is kept on a separate sheet called “data”,there is one table for start time (columns A & B) and one table for finishtime (columns D & E)
When the start & finish dates/times are entered, avlookup formula should return the unique reference, which would then populatethe Gantt chart.
I have the Gantt chart working ok, but the vlookup formulais acting strangely, and I wonder if somebody could help. It looks something like below:
[TABLE="width: 537"]
<tbody>[TR]
[TD="width: 28, bgcolor: transparent"]
1
[/TD]
[TD="width: 224, bgcolor: transparent"]
A
[/TD]
[TD="width: 76, bgcolor: transparent"]
B
[/TD]
[TD="width: 85, bgcolor: transparent"]
C
[/TD]
[TD="width: 84, bgcolor: transparent"]
D
[/TD]
[TD="width: 68, bgcolor: transparent"]
E
[/TD]
[TD="width: 75, bgcolor: transparent"]
F
[/TD]
[TD="width: 75, bgcolor: transparent"]
G
[/TD]
[/TR]
[TR]
[TD="width: 28, bgcolor: transparent"]
2
[/TD]
[TD="width: 224, bgcolor: transparent"]
Job Description
[/TD]
[TD="width: 76, bgcolor: transparent"]
WO Number
[/TD]
[TD="width: 85, bgcolor: transparent"]
Start Time
[/TD]
[TD="width: 84, bgcolor: transparent"]
Finish Time
[/TD]
[TD="width: 68, bgcolor: transparent"]
Duration
[/TD]
[TD="width: 75, bgcolor: transparent"]
Unique Start Ref
[/TD]
[TD="width: 75, bgcolor: transparent"]
Unique Finish Ref
[/TD]
[/TR]
[TR]
[TD="width: 28, bgcolor: transparent"]
3
[/TD]
[TD="width: 224, bgcolor: transparent"]
Repair temp gauge
[/TD]
[TD="width: 76, bgcolor: transparent"]
1
[/TD]
[TD="width: 85, bgcolor: transparent"]
01/02/2019 06:00
[/TD]
[TD="width: 84, bgcolor: transparent"]
01/02/2019 09:00
[/TD]
[TD="width: 68, bgcolor: transparent"]
3
[/TD]
[TD="width: 75, bgcolor: transparent"]
[/TD]
[TD="width: 75, bgcolor: transparent"]
[/TD]
[/TR]
[TR]
[TD="width: 28, bgcolor: transparent"]
4
[/TD]
[TD="width: 224, bgcolor: transparent"]
[/TD]
[TD="width: 76, bgcolor: transparent"]
[/TD]
[TD="width: 85, bgcolor: transparent"]
[/TD]
[TD="width: 84, bgcolor: transparent"]
[/TD]
[TD="width: 68, bgcolor: transparent"]
[/TD]
[TD="width: 75, bgcolor: transparent"]
[/TD]
[TD="width: 75, bgcolor: transparent"]
[/TD]
[/TR]
[TR]
[TD="width: 28, bgcolor: transparent"]
5
[/TD]
[TD="width: 224, bgcolor: transparent"]
[/TD]
[TD="width: 76, bgcolor: transparent"]
[/TD]
[TD="width: 85, bgcolor: transparent"]
[/TD]
[TD="width: 84, bgcolor: transparent"]
[/TD]
[TD="width: 68, bgcolor: transparent"]
[/TD]
[TD="width: 75, bgcolor: transparent"]
[/TD]
[TD="width: 75, bgcolor: transparent"]
[/TD]
[/TR]
</tbody>[/TABLE]


  • The formula I have in F3 is ‘=VLOOKUP(C2,Data!$A$1:$B$480,2,TRUE)’
  • The formula I have in G3 is ‘=VLOOKUP(D2,Data!$D$1:$E$480,2,TRUE)’
I thought this formula was working ok but then I noticedthat sometimes the Vlookup would return a unique reference number maybe onenumber wrong here and there.
Now, I believe the TRUE statement returns an approximatematch, I initially had it set as FALSE but the start time formula wouldn’t workeven thought the finish time formula would which is confusing me.
I had a go at trying an index match formula but couldn’t getit working either.
Could anybody on here help me with this, either with gettingthe Vlookup working accurately or even with an index match formula that woulddo the job.
Thanks
UKFoolsGold

 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
to work out the duration, instead of the vlookup what you needed is to subtract the start from the finish time

e.g.

E3 = (D3-C3)*24
 
Last edited:
Upvote 0
Hi Alan,
Thanks for the reply, the duration isn’t the problem, thatworks out by using a simple formula similar to the one you stated.
The Vlookup returns are used to auto populate a Gantt chart,the gantt chart uses the formula =AND($F3<=J$1,$G4>=J$1), obviously thisis just a single cell extract of the formula.
Apologies for the confusion.
Thanks
UKFoolsGold

 
Upvote 0
this is based on the vlookup(...,false) that works, could you provide some data the are not working here for us to test


Book1
ABCDEFG
1DateReference
201/02/2019 00:001
301/02/2019 01:002
401/02/2019 02:003
501/02/2019 03:004
6
7
8Job DescriptionWO NumberStart TimeFinish TimeDurationUnique Start RefUnique Finish Ref
9Repair temp gauge101/02/2019 00:0001/02/2019 03:00314
10
Sheet1
Cell Formulas
RangeFormula
F9=VLOOKUP(C9,$A$2:$B$5,2,0)
G9=VLOOKUP(D9,$A$2:$B$5,2,0)
 
Upvote 0
Hi Alan,

I've attached some screens below with your formula inserted.
tP0AAAAASUVORK5CYII=


x9VBBqU2JiaGwAAAABJRU5ErkJggg==


Hope this helps.

Thanks

UKFoolsGold
 
Upvote 0
don't ask, it's a pain to attach image.

are you ok to share it on a public storage, e.g. google drive?
 
Upvote 0
back to your original question, you can rid of the vlookup() with the formula in cols F & G


Book1
ABCDEFG
2Job DescriptionWO NumberStart Time dd/mm/yyyy hh:hhFinish Time dd/mm/yyyy hh:hhDuration hoursStart Time (Hour No)Finish Time (Hour No)
3
4Fix light103/05/2019 07:0003/05/2019 10:003:00810
5Fix pump203/05/2019 08:0003/05/2019 17:009:00917
6Fix spectrometer receiver303/05/2019 09:0003/05/2019 18:009:001018
7Fix leak on gland404/05/2019 06:0004/05/2019 18:0012:003142
8Clean pump strainer504/05/2019 09:0004/05/2019 17:008:003441
Gantt Chart
Cell Formulas
RangeFormula
F4=(C4-DATE(2019,5,3))*24+1
G4=(D4-DATE(2019,5,3))*24
 
Upvote 0
Thanks for that Alan, that looks great, I really appreciate the help.

One thing I've noticed though, the formula for the conditional formatting on the Gantt chart seems to be acting strangely.

It seems to work for most times but if theres a start time of 08:00, it seems to be out by one column.

E.g. if I select a start time of 05/05/2019 08:00, this references period 57 (with either the vlookup or the better formula you gave me). However when the gantt chart populates, it seems to work for the other times though, and if I manually enter 57 in the start ref cell, the gantt populates correctly. I really don't understand the problem with it.

Hope this makes sense.

Thanks

UKFoolsGold
 
Upvote 0
again, it's rounding off problems, if you amend the formula to

=ROUND((C4-DATE(2019,5,3))*24+1,0)
=ROUND((D4-DATE(2019,5,3))*24,0)

that should work
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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