View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
[email protected] tom_n_ape@hotmail.com is offline
external usenet poster
 
Posts: 4
Default Loop through rows to consolidate data

On Jan 7, 7:26*am, glp_127 wrote:
I have a simple excel file: column A is list of words and column B shows a
number. *(This will become an index of terms in a book -- column B is the
page number reference). *The list can be easily sorted, but then I need to
remove rows with duplicate words and just concatenate the page number
references in column B. *The result should look like:
word1: 1,35,160
word2: 55
word3: 3, 88

I understand the basic logic required: compare column A value to value from
previous row. *If it's the same, concatenate the column B value, delete the
current row and move on.

I'm not experienced with VBA programming though. *Does someone have some
code to start with or other ideas? *Thank-you.


....but in your comparison, don't you want to compare the word in
column A/Row i to every other word in column A? Not just the previous
row? Or, maybe if you sort the words aphabetically first that will
allow you to run a smaller comparison than the whole list in column
A. Perhaps that's what you were thinking. If it is as easy as
comparing one word to another word in the previous cell then I think
an "IF" statement in an Excel function would work easier than VBA.
You would then copy the IF statement down all cells in column C and
generate a separate column of with the results.