sounds like a job for a vba macro
you will need to sort the entries alphabetically according to the label column (peas/cararots/etc) since im using a linear search
you will need to tweak this program, as i havnt tested it.
you will have to reaplce the A() and B() arrays with the references to the exel cells. i dont know how to do this, but it should be easy to figure out.
assuming
a is the peas/carrots/etc column, and b is the frequency column,
Code:
Option Explicit
Private Sub GuichiSort()
'On Error Goto errHandler
Private const MAX_ENTRIES = 6
Dim i, j,numEntries as Integer
numEntries = MAX_ENTRIES
FOR i =1 TO (MAX_ENTRIES - 1)
IF A(i) = A(i+1)
'shuffle the duplicate entry upwards
B(i) = (B(i) + B(i+1)
'clear the entry below it
A(i+1) = vbNullString
B(i + 1) = 0
'shuffle the other entries upwards
FOR j = (i + 1) TO (MAX_ENTRIES - 1)
A(j) = A(j+1)
B(j) = B(j+1)
Next j
End If
Next i
Exit Sub
'errHandler:
'Beep
'Resume Next
End Sub
desk checking
Code:
Input -
(a) (b)
"carrots" 1
"ham" 2
"ham" 1
"peas" 4
"turkey" 1
"turkey" 1
"water" 2
i = 1
i = 2 j = (2 + 1) = 3
"carrots" 1 "carrots" 1
"ham" 3 "ham" 3
"" 0 "peas" 4
"peas" 4 "turkey" 1
"turkey" 1 "turkey" 1
"turkey" 1 "water" 2
"water" 2
i = 3
i = 4 j = (4 + 1) = 5
"carrots" 1 "carrots" 1
"ham" 3 "ham" 3
"peas" 4 "peas" 4
"turkey" 2 "turkey" 2
"turkey" 1 "water" 1
"water" 1 "" 1
i = 5
[program terminates]
ActiveSheet.Range.Cells(x,x)