Function to return a value

Aspharagus

New Member
Joined
Aug 18, 2024
Messages
9
Office Version
  1. 365
Platform
  1. Windows
Hello Everyone,

I am looking for a function which returns the previous and next value, For example,

If I am looking for 130 which is lies between 120 and 140, The function should return the value 120 and 140.


Thank you.
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Assuming your cell with the value of 130 is in A1. how about:

Excel Formula:
=LET(val,A1,HSTACK(val-10,val+10))
 
Upvote 0
Can you post some sample data.

MrExcel has a tool called “XL2BB” that lets you post samples of your data that will allow us to copy/paste it to our Excel spreadsheets, so we can work with the same copy of data that you are. Instructions on using this tool can be found here: XL2BB Add-in

Note that there is also a "Test Here” forum on this board. This is a place where you can test using this tool (or any other posting techniques that you want to test) before trying to use those tools in your actual posts.
 
Upvote 0
Hi,

Sorry, I am getting error saying my computer is protected and I cannot install the xl2BB file.
anyway, here is a sample table.
I am trying to create a linear interpolation equation, which calculates the value from 2nd column. the first column represents the angle.
The value I am looking for, can lie anywhere between 0 to 360 degrees. i have provided value upto 90 degree in below table.
Let's say If I want to find value for 32 degree, the function need to calculate the range in which it falls that is 30 and 60.


00.723
300.523
600.633
900.661
 
Upvote 0
Ok, how about
Fluff.xlsm
ABCDEF
100.723
2300.523320.5230.633
3600.633
4900.661
Data
Cell Formulas
RangeFormula
E2:F2E2=XLOOKUP(D2,A1:A4,B1:B4,,{-1,1})
Dynamic array formulas.
 
Upvote 0
Hi Fluff,

I have that function, it returns the value of the second column. but is there anyway to get 30 and 60 from first column?

Thanks.
 
Upvote 0
Just change the range in the 3rd argument from col B to col A
 
Upvote 0
You're welcome & thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,263
Members
452,627
Latest member
KitkatToby

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