I have an Excel VBA that I created. It generates an output based on an input file.
In that file, there is a field that contains usernames, these usernames are repeated throughout the column.
What I need to do is, assign the usernames to separate cells to be unique not repeated, and then count the repeated ones.
Suppose I have my excel worksheet setup as follows:
In column C I want a count of how many of each name there are
I can do this in VBA by putting the usernames into a dictionary where the
Key
is the username and theValue
is the number of repetitions. I then just iterate over the dictionary to get the desired output.This code worked for me:
NB: you may need to do Tools > References > Microsoft Scripting Runtime to get the dictionary to work