Choosing the best cell

citrusfish

New Member
Joined
Nov 24, 2015
Messages
11
Hi

This post has two requests

I have the data shown below:


[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD="align: center"][/TD]
[TD="align: center"]A[/TD]
[TD="align: center"]B[/TD]
[TD="align: center"]C[/TD]
[TD="align: center"]D[/TD]
[TD="align: center"]E[/TD]
[TD="align: center"]F[/TD]
[/TR]
[TR]
[TD="align: center"]1[/TD]
[TD="align: center"]Target 1[/TD]
[TD="align: center"]Target 2[/TD]
[TD="align: center"]Value of Target 1[/TD]
[TD="align: center"]Value of Target 2[/TD]
[TD="align: center"]Best Target[/TD]
[TD="align: center"]Best Value[/TD]
[/TR]
[TR]
[TD="align: center"]2[/TD]
[TD="align: center"]5[/TD]
[TD="align: center"]4[/TD]
[TD="align: center"]-0.78[/TD]
[TD="align: center"]2.22[/TD]
[TD="align: center"][/TD]
[TD="align: center"][/TD]
[/TR]
</tbody>[/TABLE]

I would like to research two possible options as I am not sure which will suit my purpose best:

1. Return in F2 the value of C2 or D2 which is closest to 0 and then copy the corresponding Target depending on whether Value Target 1 or Value Target 2 was the closest. So it would return -0.78 in F2 and 5 in E2.


2. Slightly easier I think. I want to return in F2 the Positive value from C2 or D2 and then copy the corresponding Target depending on whether Value Target 1 or Value Target 2 was the closest. So it would return 2.22 in F2 and 4 in E2.

I hope it is OK to ask two questions in one.

Many thanks for any help you can give.

Citrusfish
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi,

If your real data is as straight forward as your sample:


Book1
ABCDEFG
1Target 1Target 2Value of Target 1Value of Target 2Best TargetBest Value
254-0.782.225-0.78<--Question 1
354-0.782.2242.22<--Question 2
Sheet369
Cell Formulas
RangeFormula
E2=IF(ABS(C2)D2),A2,B2)
E3=IF(ABS(C3)>ABS(D3),A3,B3)
F2=IF(ABS(C2)D2),C2,D2)
F3=IF(ABS(C3)>ABS(D3),C3,D3)
 
Upvote 0
Re: Choosing the best cell [SOLVED}

You're welcome, and in re-reading your Question 2, I've made a mistake in my answer for question 2, we need to take Out the ABS function like follows:


Book1
ABCDEFG
1Target 1Target 2Value of Target 1Value of Target 2Best TargetBest Value
254-0.782.225-0.78<--Question 1
354-2.782.2242.22<--Question 2
Sheet369
Cell Formulas
RangeFormula
E2=IF(ABS(C2)D2),A2,B2)
E3=IF(C3>D3,A3,B3)
F2=IF(ABS(C2)D2),C2,D2)
F3=IF(C3>D3,C3,D3)
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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