简体   繁体   中英

Looping through names and storing values that are not duplicates

I am using excel and I have names of employees in column "A" of a worksheet. I want to loop through the names and store all the non-duplicate names in a variable. Once the Vba code loops through all the names in column "A" and all the non-duplicates are stored in a variable, I want to variable value to be placed in cell "B1". Every time the Vba code loops and finds a non-duplicate, I want to enter a " / " between the names.

Ex: column "A" values A1 = "Mark" A2 = "Berry" A3 = "Tom" A4 = "Mark" A5 = "Dan" A6 = "Berry" A7 = "Dennis" The names are just text values, nothing special.

In column "B1" I would like the following text string: "Mark / Berry / Tom / Dan / Dennis"

I wrote a vba program that copied column "A" and pasted it into column "B", deleted the duplicate and ran a "for" loop to capture all the names until it becomes blank. I was just seeing if there was an easy way with an "if" statement that could look to see it what is in a particular column if a duplicate or not.

Thank you for all your input, I'm sorry I was not more specific the first time.

You can add a print statement to your loop where you can have

System.our print(B1 [i] + " / " );

This should print out the name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM