Привет, есть ли способ очистить дубликаты на основе имени? В прошлый раз я уже спрашивал, как удалить дубликаты, и вот вывод
Col 2 | Col 1
Person 1 | 1. Question 1
| 2. Question 2
| 3. Question 3
-------------------------
Person 2 | 1. Question 1
| 2. Question 2
| 3. Question 3
-------------------------
Person 3 | 1. Question 1
| 2. Question 2
| 3. Question 3
Я добавляю еще один столбец, который является столбцом 3, где он может видеть статус.
Col 2 | Col 1 | Col 3
Person 1 | 1. Question 1 | CLEAN
| 2. Question 2 | CLEAN
| 3. Question 3 | CLEAN
-------------------------
Person 2 | 1. Question 1 | CLEAN
| 2. Question 2 | CLEAN
| 3. Question 3 | CLEAN
-------------------------
Person 3 | 1. Question 1 | CLEAN
| 2. Question 2 | CLEAN
| 3. Question 3 | CLEAN
Я хочу, чтобы это было так:
Col 2 | Col 1 | Col 3
Person 1 | 1. Question 1 | CLEAN
| 2. Question 2 |
| 3. Question 3 |
-------------------------
Person 2 | 1. Question 1 | CLEAN
| 2. Question 2 |
| 3. Question 3 |
-------------------------
Person 3 | 1. Question 1 | CLEAN
| 2. Question 2 |
| 3. Question 3 |
кстати, вот код:
Sub RemoveDups(src As Range, dst As Range)
Dim i As Integer, j As Integer, tmp, temp()
' Copy source range
temp = src.Value
' Sort data
For i = LBound(temp, 1) To UBound(temp, 1) - 1
For j = i + 1 To UBound(temp, 1)
If (temp(i, 2) > temp(j, 2)) Or ((temp(i, 2) = temp(j, 2)) And (temp(i, 1) > temp(j, 1))) Then
tmp = temp(i, 1)
temp(i, 1) = temp(j, 1)
temp(j, 1) = tmp
tmp = temp(i, 2)
temp(i, 2) = temp(j, 2)
temp(j, 2) = tmp
End If
Next j
Next i
' Clear vertical dups
For i = UBound(temp, 1) - 1 To LBound(temp, 1) Step -1
If temp(i + 1, 2) = temp(i, 2) Then
temp(i + 1, 2) = ""
End If
Next i
' Swap columns
For i = LBound(temp, 1) To UBound(temp, 1)
tmp = temp(i, 1)
temp(i, 1) = temp(i, 2)
temp(i, 2) = tmp
Next i
' Store result
dst.Value = temp
End Sub
Я попытался добавить под 'четкие вертикальные дупла
If temp(i + 1, 3) = temp(i, 3) Then
temp(i + 1, 3) = ""
End If
но это дает мне такой вывод:
Col 2 | Col 1 | Col 3
Person 1 | 1. Question 1 | CLEAN
| 2. Question 2 |
| 3. Question 3 |
-------------------------
Person 2 | 1. Question 1 |
| 2. Question 2 |
| 3. Question 3 |
-------------------------
Person 3 | 1. Question 1 |
| 2. Question 2 |
| 3. Question 3 |
Помоги мне!! Спасибо!