0

I have a column of numbers, that have to be sorted like this:

I have one number in A1, which is the precise value from I start -e.g. 10 and then I have numbers like: 9, 8.1, 11, 6, 10.5

My goal is to sort them from the least different. It means:

10, 10.5, 11, 9, 8.1, 6.

In Java it would be done by compareTo function. Is there something like this is VBA?

0

1 Answer 1

4

If no cleaner way exists you could try the following workaround :

define a distance function like this : abs(x - from) and sort by its results, maybe in a temporary/hidden sheet if you want to apply sort in a transparent manner.

Sign up to request clarification or add additional context in comments.

1 Comment

+1 that seems clean enough to me :). I'd just put it in a column, hidden or otherwise, in the same sheet. (You might want to edit the first word of your answer for future generations.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.