View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default If value occurs more than once then delete all of them

Hi Howard,

Am Sun, 6 Jul 2014 21:18:22 -0700 (PDT) schrieb L. Howard:

If a value in varData occurs more than once, then delete all same values in varData and list remaining values in column F.


try:

Sub LoneValueStay2()
Dim varData() As Variant
Dim rngC As Range
Dim i As Long

With Sheets("Sheet1")
ReDim Preserve varData(65)
For Each rngC In .Range("A2:D15")
If WorksheetFunction.CountIf(.Range("A2:D15"), rngC) = 1
Then
varData(i) = rngC
i = i + 1
End If
Next

'// Write result to sheet.
.Range("F1").Resize(UBound(varData) + 1, 1) = _
Application.Transpose(varData)
End With
End Sub


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional