Need to improve formula or VBA.

Russk68

Well-known Member
Joined
May 1, 2006
Messages
589
Office Version
  1. 365
Platform
  1. MacOS
Hi all!

I am using this formula (below) to return a result based on a number in the example below. Sheet1, Column A is an ID start number and B is an item.


Sheet 1 data entry
A...............B
1............Apple
50..........Banana
201........Orange

Sheet 2, column A is where I enter a number to get a result in column B. Any number between 1 and 49 will result Apple. a number 50:200 will result Banana and so on.
Sheet 2, column B formula =IFERROR(INDEX(Instruments!$AX$3:$AX$40,MATCH('Patch By UNIVERSE'!A5,Instruments!$A$3:$A$40,1)),"")

Example result sheet 2:

A...............B
3.............Apple
17...........Apple
57...........Banana
199.........Banana
200.........Banana
201.........Orange
378.........Orange

This formula works as long as the ID start numbers in sheet1, column A, are in ascending order. I would like to enter start IDs in any order to get the desired result.

Can a formula do this or is VBA the way to go?

Thank you!
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
This formula works as long as the ID start numbers in sheet1, column A, are in ascending order. I would like to enter start IDs in any order to get the desired result.
Can't you enter your start ID's and their description in any order and then immediately sort those two columns in ascending order keyed to the ID column?
 
Upvote 0
I think the only formula alternative (that I could come up with quickly) is to have column A be the low end of the range and column B be the high end, with your results in column C.

Then, on your Sheet2 in the B column, this should work:

Code:
=INDEX(Sheet1!$C$1:$C$3,SUMPRODUCT((A1>=Sheet1!$A$1:$A$3)*(A1<=Sheet1!$B$1:$B$3)*ROW($1:$3)),1)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,265
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