VLOOKUP / Range?

Status
Not open for further replies.

Watsoa

New Member
Joined
Mar 2, 2011
Messages
8
Hi guys,

I want to perform a lookup function that will find a given value within a range. Ie, user inputs 100 to a cell, and lookup will retrieve an approximate match +-5 from column 1 and display adjacent cell in column 2.

A standard vlookup true statement with a range i guess? (search for approximately 100 between 95-105).

Im still learning VBA so any help would be brilliant.

Thanks
A:confused:
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Here's something to get you started:
Code:
Function vlookuptol5(needle, searchrange As Range)
    Application.Volatile
    vlookuptol5 = "Not found"
    For Each c In searchrange
        If Abs(c.Value - needle) <= 5 Then
            vlookuptol5 = c.Offset(0, 1).Value
            Exit For
        End If
    Next
End Function
... used in a cell like this:
=vlookuptol5(100,A2:A60)
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,224,590
Messages
6,179,750
Members
452,940
Latest member
rootytrip

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