VLOOKUP Isssue

sguirgies

New Member
Joined
Oct 25, 2024
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I'm developing a sprdeadsheet using MROUND and VLOOKUP.

The VLOOKUP acts strange when the MROUND cell displays a result of 2:30, 3:30...+ but not otherwise. it returns the result for 2:15, 3:15...+. If i override the MROUND and enter 2:30 manuallly it works. Paste special does not work.

I have checked the result of the MROUND using ISNUMBER and LEN, it is the same value as the VLOOKUP it looking for.

PLEASE HELP.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
is this a TIME value you are returning from vlookup
and what is Mround expected to do

perhaps post the formula you are using

A SMALL sample spreadsheet, around 10-20 rows, would help a lot here, with all sensitive data removed, and expected results mocked up and manually entered, with a few notes of explanation.

This will possibly enable a quicker and more accurate solution for you.

MrExcel has a tool called “XL2BB” that lets you post samples of your data and will allow us to copy/paste your sample data into our Excel spreadsheets, saving a lot of time.

You can also test to see if it works ok, in the "Test Here" forum.

OR if you cannot get XL2BB to work, or have restrictions on your PC

then put the sample spreadsheet onto a share

I only tend to goto OneDrive, Dropbox or google docs , as I'm never certain of other random share sites and possible virus.
Please make sure you have a representative data sample and also that the data has been desensitised, remember this site is open to anyone with internet access to see - so any sensitive / personal data should be removed

Make sure you set any share or google to share to everyone
 
Upvote 0
thanks for the spreadsheet
I have no idea what I should be looking at , no explanation of what cells you are using
can you provide an explanation and the expected results

The spreadsheet opened in column N - no formula
i see a vlookup in O
and a blank range highlighted in Q12 - Q14

=IFS(

H2="Yes",VLOOKUP(A!F2,'Pricing Main'!$A$1:$C$11,3),
I2="phone",VLOOKUP(A!F2,'Pricing Main'!$A$13:$C$28,3),
I2="video",VLOOKUP(A!F2,'Pricing Main'!$A$31:$C$48,3))

As you dont have TRUE or FALSE at the end of the vlookup - it will default to TRUE and find the nearest lower value in the column MAIN A


i have downloaded to excel and also made available here as XL2BB in case other members dont want to go to onedrive and can see whats going on and maybe help

sdd mock.xlsx
ABCDEFGHIJKLMNOPQ
1Time inTime outBilled timeOnsiteLocation$
214:0015:001:30Yes10
315:3016:000:30NoVideo1
49:0017:008:00NoVideo15
510:4511:150:30NoVideo1
615:0016:001:00NoPhone3
74:30 PM5:30 PM1:00NoVideo3
89:00 AM4:00 PM7:00No#N/A
910:00 AM1:00 PM3:00Yes47
101:00 PM2:00 PM1:00NoVideo3
111:00 PM2:00 PM1:30Yes10
1210:00 AM11:00 AM1:30Yes10
1311:00 AM12:30 PM1:30NoPhone5
1410:30 AM11:30 AM1:30Yes10
151:30 PM2:30 PM1:00NoVideo3
1610:00 AM11:00 AM1:30Yes10
173:00 PM3:30 PM0:30NoVideo1
189:30 AM11:00 AM1:30Yes10
1911:10 AM1:40 PM2:30NoPhone8
2011:30 AM1:30 PM2:00Yes20
213:00 PM4:00 PM1:00NoPhone3
224:30 PM5:30 PM1:00NoPhone3
239:00 AM11:30 AM2:30Phone8
A
Cell Formulas
RangeFormula
F2:F22F2=IF(H2="Yes",IF((E2-D2<3/48),3/48,MROUND((E2-D2),1/48)),MROUND(E2-D2,1/96))
O2:O23O2=IFS(H2="Yes",VLOOKUP(A!F2,'Pricing Main'!$A$1:$C$11,3),I2="phone",VLOOKUP(A!F2,'Pricing Main'!$A$13:$C$28,3),I2="video",VLOOKUP(A!F2,'Pricing Main'!$A$31:$C$48,3))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
H1,P:P,H33:H1048576Cell Valuecontains "No"textNO


sdd mock.xlsx
ABCD
1Onsite
21:3010
32:0020
42:3030
53:0047
63:3050
74:0060
84:3070
95:0080
105:3090
116:00100
12
13Telephone
140:3030m1
150:4545m2
161:0060m3
171:1575m4
181:3090m5
191:45105m6
202:00120m7
212:15135m8
222:30150m9
232:45165m10
243:00180m11
253:15195m12
263:30210m13
273:4514
284:0015
29
30
31Video
320:3030m1
330:4545m2
341:0060m3
351:1575m4
361:3090m5
371:45105m6
382:00120m7
392:158
402:30150m9
412:4510
423:00180m11
433:1512
443:30210m13
453:4514
464:0015
47
Pricing Main
 
Upvote 0
Apologies I didn't actually realise how convoluted is looked when I scrubbed sensitive data.

In sheet A, Column D and E, time in and out, H whether it's onsite or not, I if not onsite is it video or phone (I scrubbed addresses). column F is based on the above but essentially I want the difference between D and E. If it's onsite, I want it rounded up to the nearest half hour with a minimum of 1.5 hours, if not I want it rounded up to the nearest 15 minutes with a 0.5 hour minimum. I knoow I need to tweak that formula, including a similar nested if for a minimum of 0.5 hours where the initial if is not satisfied possibly using ROUNDUP innstead of MROUND.

Following that:
There is a IFS with VLOOKUPs as conditions in O to grab from the appropriate table in the second tab. My issue is if I alow the formula in F to calculate 2.5 hours the VLOOKUP returns the value for 2:15 in the correct table (same issue with 3:30, returns 3:15 but other vauesare fine). If I manually type 2:30 (or 3:30) it returns the value it should. Why is it breaking?

Thank you for your effort.
 
Upvote 0
i think part of the issue maybe the floating point error in excel
i change to use false so that vlookup using an exact match and it failed with a lot of N/A, so a time calculation by formula - does not match an entry manually - hence the issue you are getting


not sure at the moment on best way to fix with the time issue - other members may help here

I tested 2:30 on F19
with the value in A22
and changed to general
0.104166667000000000
and they both matched visually

BUT if i copied to E22 and did a
A22=E22 , then i get a false
 
Upvote 0
A couple of preliminary comments
  • Your formula is on sheet 'A' and you have used that sheet name in your formula: =IFS(H2="Yes",VLOOKUP(A!F2,'Pricing Main'!$A$1:$C$11,3),I2="phone",VLOOKUP(A!F2, .....
    That is not needed and in fact a bad idea as it can lead to unflagged errors in some instances. Example of this problem you can see/test here

  • IFS is an inefficient function and I would recommend against it. Inefficient because it checks every condition and calculates every result even if the first condition turns out to be the used one. Nested IF functions, or sometimes other options are generally more efficient
I believe that the floating point issue that @etaf has raised is the issue for you. My suggestion is to name the 3 lookup tables on 'Pricing Main' and try the formula shown in col P below.
I have rounded all the time values in the formula.

sguirgies sdd mock.xlsx
DEFGHIOP
1Time inTime outBilled timeOnsiteLocationOriginalSuggested
214:0015:001:30Yes1010
315:3016:000:30NoVideo11
49:0017:008:00NoVideo1515
510:4511:150:30NoVideo11
615:0016:001:00NoPhone33
74:30 PM5:30 PM1:00NoVideo33
89:00 AM4:00 PM7:00No#N/A#N/A
910:00 AM1:00 PM3:00Yes4747
101:00 PM2:00 PM1:00NoVideo33
111:00 PM2:00 PM1:30Yes1010
1210:00 AM#######1:30Yes1010
1311:00 AM#######1:30NoPhone55
1410:30 AM#######1:30Yes1010
151:30 PM2:30 PM1:00NoVideo33
1610:00 AM#######1:30Yes1010
173:00 PM3:30 PM0:30NoVideo11
189:30 AM#######1:30Yes1010
1911:10 AM1:40 PM2:30NoPhone89
2011:30 AM1:30 PM2:00Yes2020
213:00 PM4:00 PM1:00NoPhone33
224:30 PM5:30 PM1:00NoPhone33
239:00 AM11:30 AM2:30Phone89
A
Cell Formulas
RangeFormula
O2:O23O2=IFS(H2="Yes",VLOOKUP(A!F2,'Pricing Main'!$A$1:$C$11,3),I2="phone",VLOOKUP(A!F2,'Pricing Main'!$A$13:$C$28,3),I2="video",VLOOKUP(A!F2,'Pricing Main'!$A$31:$C$48,3))
P2:P23P2=LET(tbl,IF(H2="Yes",Onsite,IF(I2="phone",Telephone,IF(I2="video",Video,NA()))),MAX(FILTER(TAKE(tbl,,-1),ROUND(TAKE(tbl,,1),8)<=ROUND(F2,8),NA())))
F2:F22F2=IF(H2="Yes",IF((E2-D2<3/48),3/48,MROUND((E2-D2),1/48)),MROUND(E2-D2,1/96))
Named Ranges
NameRefers ToCells
Onsite='Pricing Main'!$A$2:$C$11O2:P23
Telephone='Pricing Main'!$A$14:$C$28O2:P23
Video='Pricing Main'!$A$32:$C$46O2:P23
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,111
Members
453,021
Latest member
Justyna P

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