Miten saan tästä koodista sellaisen, että jos en halua riviä poistettavaksi, eli valitsen ettei sitä poisteta, solu ei jää enää punaiseksi vaan palautuu siihen mitä se olikin ?
Sub aaa()
Range("A:A").Interior.ColorIndex = xlNone
For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
If WorksheetFunction.CountIf(Range("A1:A" & i), Cells(i, 1).Value) > 1 Then
Cells(i, 1).Interior.ColorIndex = 3
If MsgBox("Duplicates highted...Do you want to delete", vbYesNo) = vbYes Then
Cells(i, 1).EntireRow.Delete
End If
End If
Next i
End Sub
Kiitollisena vastausta odotellen
Sub aaa()
Range("A:A").Interior.ColorIndex = xlNone
For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
If WorksheetFunction.CountIf(Range("A1:A" & i), Cells(i, 1).Value) > 1 Then
Cells(i, 1).Interior.ColorIndex = 3
If MsgBox("Duplicates highted...Do you want to delete", vbYesNo) = vbYes Then
Cells(i, 1).EntireRow.Delete
End If
End If
Next i
End Sub
Kiitollisena vastausta odotellen
Vastaukset 1
Vanhimmat
Sub aaa()
Range("A:A").Interior.ColorIndex = xlNone
For i = Cells(Rows.Count, 1).End(xlUp).Row To 2 Step -1
If WorksheetFunction.CountIf(Range("A1:A" & i), Cells(i, 1).Value) > 1 Then
Cells(i, 1).Interior.ColorIndex = 3
If MsgBox("Duplicates highted...Do you want to delete", vbYesNo) = vbYes Then
Cells(i, 1).EntireRow.Delete
Else
Range("A:A").Interior.ColorIndex = xlNone
End If
End If
Next i
End Sub