# Help with Apple Script for dealing with duplicates in Numbers

I had a script that I used to find duplicates in a numbers document and to highlight the duplicate in red.

Well I now have a file where there are multiples of the descriptor in column B that are duplicates, but the code for the descriptor in column A is different and it's truly not a duplicate. What I now need the script to do is not make it red, but to put the code from column A for any duplicates it finds after the descriptor in column B and to leave column A alone.

My attempt to get this to work broke my script and I don't know how to fix it.

How can I get this script to do what I need so I'm not having to do thousands of lines manually?

Below is the script I have. The part where it says merge cell is where I took out the make it red part.

tell application "Numbers" to tell front document to tell active sheet

set selected_table to first table whose class of selection range is range

tell selected_table

set selected_range to the selection range

tell selected_range

set values_list to {}

repeat with i from 1 to count cells

set this_value to value of cell i as text

if values_list contains this_value then
merge cell 1 of column 1 of selected_table with column 2 of selected_table
end if
set end of values_list to this_value

end repeat

end tell

end tell

end tell


Below is a screenshot of the Numbers document:

• Firstly, welcome to Ask Different! :) I hope you come to find this site useful! As for your question, do you have a copy of the script before you changed it? At present we don't know what changes you actually made. As for the screenshot, can you add some context as to what you're trying to show us by including it? I assume you're trying to show what you're wanting the script to do, but that's not really clear. – Monomeeth May 17 at 1:48
• You said, "My attempt to get this to work broke my script and I don't know how to fix it.", well don't you have a working backup copy of the script!? – user3439894 May 17 at 1:49
• It's also not clear from the screenshot how you're wanting to define what a duplicate is (e.g. it shows EMADEQS and MADEQS, but following that logic wouldn't MADEQL in the next row also have to be captured because MADEQ appears in all three of the codes in Column A? – Monomeeth May 17 at 1:52
• I was an idiot and didn't realize that I didn't have another copy. But I had sent a copy to a friend to use. I'll get it from her and post it. Also the copy that is being turned red is the Descriptive. So like Anal Gland Expression - there are 2 of them. In this screen shot the Code at the end was manually placed. But that is what I want the new script to do. Which is when it finds the double description to take the code in column 1 and throw it on the end of column 2 to make the whole line a unique identifier. Does that better explain? – Tina Brunnet May 21 at 17:14
• Here is the original Script: – Tina Brunnet May 21 at 21:52