Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding nearest value in a lookup table

Status
Not open for further replies.

UKpete

Electrical
Jan 6, 2002
463
I have an Excel spreadsheet that calculates a series of resistor values from some test data. The problem I have is that I want the spreadsheet to select the nearest available values of resistance from a table of preferred values, a common enough type of problem I would have thought.

Is there an Excel function that will do this or is it time I got to grips with Visual Basic?

Thank you
Peter
 
Replies continue below

Recommended for you

Look through the help file on VLOOKUP and HLOOKUP. There is an optional paramter that defines the type of match (exact, etc.).
 
When you have a value between the available series of resistance, the default match type for LOOKUP and MATCH picks the lower value (list is sorted in ascending order). You can, as an option, select an exact match type (tabvle need not be sorted), or the next higher match (table sorted in descending order). When you need to strictly pick the closest match, that could be more involved - does anyone have a tip for that?
 
you could lookup the next higher cell and look up the next lower cell and determine the one that has the lower absolute value of difference to your lookup target... use that information in an if function to access the data you want (may require index function to help lookup other stuff on the same row).

=====================================
Eng-tips forums: The best place on the web for engineering discussions.
 
Well I have managed it with your combined help thanks, though it doesn't look too pretty (and I'm mentally a bit drained).

I've got two columns of preferred values, one ascending the other descending, and a MATCH function for each, then an IF statement to get the closest value.

As electricpete says (Pete, in cricket terms, you're an all-rounder!) I have to use an INDEX function with each MATCH function as the latter gives a cell reference rather than the actual value.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor