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:
Date
Reference
01/02/2019 00:00
1
01/02/2019 01:00
2
01/02/2019 02:00
3
01/02/2019 03:00
4
And so on…
<tbody> </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:
1
A
B
C
D
E
F
G
2
Job Description
WO Number
Start Time
Finish Time
Duration
Unique Start Ref
Unique Finish Ref
3
Repair temp gauge
1
01/02/2019 06:00
01/02/2019 09:00
3
4
5
<tbody> </tbody>


  • 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

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
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,215,461
Messages
6,124,955
Members
449,199
Latest member
Riley Johnson

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