Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an excel spread sheet with about 9 columns and each have circa 170 rows.

What is the best method to find two rows that match a rule, then moves one of the items to a location that is atleast 2 cells away from the other item for each column.

For example

Cat and Dog can't be in two rows next to each other:

----------
cat      |
----------
dog      |
----------
fish     |
----------
bird     |
----------
bear     |
----------

Would become something like:

----------
cat      |
----------
bird     |
----------
fish     |
----------
dog      |
----------
bear     |
----------

If you would like anymore information please ask.

Also: I used the mac tag, as there wasn't one for mac-excel (or I couldn't see it), so sadly no visual basic, if this is wrong mods please correct me.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

There may be fancier ways of doing this but I would do this manually using extra columns.

In column J, have an index number, being the row number in the range.

In column K, have zero in the first row and in subsequent rows the formula:=IF(AND(A2="dog",A1="cat"),1.5,0)

Have column L be the sum of these two numbers, and then sort on the values in column L.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.