Excel (Help) automatically extracts unique names with VBA.

Give examples.

For example, there is a table as shown in the following figure:

You need to delete duplicate values after taking out the names in column A, and then output them to column C. ..

Step 1: Click the development tool-Visual Basic. Select sheet 1 and enter the following code:

Subname to copy ()

Dim jgArr( 1 to 100)

zz = 0

Worksheet ("Worksheet 1"). Make active

set ZD = CreateObject(" scripting . dictionary ")

hh = 2

Do While cell (hh,1) < & gt""

If it is not zd.exists (cell (hh, 1)). Text) and then

zd。 Add a cell (hh, 1). Text, zz

zz = zz + 1

JgArr(zz) = cell (hh, 1). text

If ... it will be over.

hh = hh + 1

ring

Output result

Scope ("c2:c 100000"). Clear content

For i = 1 to zz

Cells(2 + i - 1,3) = jgArr(i)

Next, I

End joint

Step 2: Click on the macro and select Delete Duplicate Macro. As shown in the figure:

Click Execute, and the result is shown in the figure below: