vba match a range of numbers

monsierexcel

New Member
Joined
Nov 19, 2018
Messages
29
hey guys, i have a VBA coding problem and i am not sure if i need to write in index/match formula into my vba or if theres a better way to build this.

I have a list of numbers
[TABLE="width: 500"]
<tbody>[TR]
[/TR]
[TR]

[/TR]
[TR]
[TD][TABLE="width: 500"]
<tbody>[TR]
[TD]1
[/TD]
[TD]test1
[/TD]
[/TR]
[TR]
[TD]3
[/TD]
[TD]test2
[/TD]
[/TR]
[TR]
[TD]5
[/TD]
[TD]test3
[/TD]
[/TR]
[TR]
[TD]8
[/TD]
[TD]test4
[/TD]
[/TR]
[TR]
[TD]11
[/TD]
[TD]test5
[/TD]
[/TR]
[TR]
[TD]13
[/TD]
[TD]test6
[/TD]
[/TR]
[TR]
[TD]15
[/TD]
[TD]test7
[/TD]
[/TR]
</tbody>[/TABLE]

[/TD]
[/TR]
</tbody>[/TABLE]

SO with this table iif my value produces "6" i want it to produce test 3 - as 5 is the nearest
I think its index/match i require but not sure how to write it in VBA?

thanks guys
 

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
This would do it as a formula (with CTRL-SHIFT-ENTER). Are you writing the value back to the sheet in your VBA code or what are you trying to do with that?


Excel 2010
ABCDE
11test16
23test2test3
35test3
48test4
511test5
613test6
715test7
Sheet1
Cell Formulas
RangeFormula
E2{=INDEX(B1:B7,MATCH(MIN(ABS($E$1-A1:A7)),ABS($E$1-A1:A7),0))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,170
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