QUOTE(Christian J @ May 29 2012, 11:14 AM)
QUOTE(denmarks @ May 29 2012, 01:37 AM)
I want an automated way to count the number of people attending each event. Right now I manually count them and since changes are made often I sometimes make a mistake.
It's relatively easy to find an occurence of say letter A in a cell, and then add up all such occurences. Duplicates can then be excluded from the count (that is, multiple A letters in a cell still just count as one).
Do you also want to remove duplicates in each cell for "esthetic" reasons? That's more tricky (=bug prone), especially if there are linebreaks etc in the code.
There will never be duplicates since I an entering the letters. There are no forced line breaks. There is a space between each letter.
I need to do 2 things. I need a way to do a loop through the cells that will work for any browser. The contents of a cell will then be assigned to a variable. This is where I had a problem of it working for Firefox and not IE. I have found routines that will accumulate numbers in the cells and I tried to alter one of them. The problem occurred when trying to place the contents of the cell into a variable. It worked in Firefox but was null in IE. Sorry I did not keep the code.
Now I need the best way to accumulate the count of each letter. I do not want to create 26 if statements. There must be a more esoteric way to do a scan of the variable and for each letter add one to its corresponding accumulator. I believe that arrays can be indexed by a name (letter) rather than occurrence number. My first try was with 26 if statements and 26 variables. This is too much code. There must be an easier way.
Note that I do this for fun and as a learning experience, not because it must be done. Obviously I can continue to do the count manually. I only want to program it if it can be done with a relatively short routine.
Once I have the accumulation I have no problem putting it on the page. I do it with date counts now.