Find closest values

jokei

New Member
Joined
Aug 5, 2015
Messages
8
Hi,
I'm new to macros and can't find a good starting point for my problem.

I want to loop through a row in a table looking for the 3 closest numbers (column D) to a value in a given cell (N5) and set the corresponding row to "yes" in column B.
So if the 3 closest values is found in D3, D6 and D7 I want B3, B6 and B7 to say "Yes" and then filter my list accordingley.

Help appreciated.

Regard Jokei
 
Thanks! I really appreciate your help.
What I ended up doing was writing the result for each data column in different columns and then combining them in a separate column with a simple IF formula. I found the first version of the code much easier to understand if I need to maintain it going forward.
Thanks again, this really allowed me to have unexpected progress on my work.
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Glad it helped you. BTW, after posting #10, I realized that I had left an Offest in the last line of code. It was there for testing and should be removed.

VBA Code:
' right code
rngDestination.Resize(UBound(arrResult), 1).Value = Application.Transpose(arrResult)
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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