You'll have to modify this for your purposes, but I figure it will probably point you the right direction.
Basically, it pulls your datagrid data into a temporary array, cycles through the rows (tKey is the current row index during the repeat loop)
During the loop it fills a new array, keyed by customer name. If there is no entry for the current key being checked, it creates an entry and puts the row index into the contents. If the key already exists, it adds the current index as an item (comma delineated list) this way you have the same number of keys as you do unique records, and you can track where duplicates are.
Not sure how clear this is, but hopefully will be of some help.
## Edited 6:10 PM to try and make the code clearer.
Code: Select all
on mouseUp
put the dgdata of group 1 into tArrayA -- copy datagrid contents to array
repeat for each key tKey in tArrayA -- cycle through 'rows' of array, tKey is the row index
-- set tKeyVal to the contents of the customer name column for the row
put tArrayA[tKey]["Customer Name"] into tKeyVal
--check to see if theres already an array key of our new array (tNewArrayA) that
--matches the current customer name and if not..
if tNewArrayA[tKeyVal] is empty then
-- create new array keyed by tKeyVal
put tKey into tNewArrayA[tKeyVal]
--if there IS already a value in the tNewArray for the current customer name key then
else
-- add another item to the keyed entry to track duplicates
put comma & tKey after tNewArrayA[tKeyVal]
end if
end repeat
-- this just prints an explanatory message to the msg box with # of unique rows based on customer name
put "There are " & the number lines in the keys of tNewArrayA && "unique records" & return
-- outputs the number of keys created, thereby giving a count without dupes
-- this just cycles through our new array and displays the datagrid
--index numbers matching each customer name
repeat for each key tKey in tNewArrayA
put "The name " & tKey && "appears in row(s): " & tNewArrayA[tKey] & return after msg
end repeat
end mouseUp