Hello Jon,
Welcome to the Forum!
The code I have added will remove duplicates in columns "A" and "B". The deletion process starts at the end of range and goes up. Where N is the last row, if row N - 1 = row N then cells "A" and "B" of row N - 1 are deleted. If cell "A" of row N - 1 has a value then that value is copied to cell "A" of row N before row N - 1 is deleted.
' Retrieve software info
Dim I As Long
Dim Rng As Range
Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE
strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\"
strEntry1a = "DisplayName"
strEntry1b = "QuietDisplayName"
Set objItem = GetObject("winmgmts://" & objComp & "/root/default:StdRegProv")
objItem.EnumKey HKLM, strKey, arrSubkeys
ActiveSheet.Range("A" & QueryStart & "").Value = "Software"
StartSort = QueryStart
'MsgBox "Start Value " & StartSort
For Each strSubkey In arrSubkeys
intRet1 = objItem.GetStringValue(HKLM, strKey & strSubkey, strEntry1a, strValue1)
If intRet1 <> 0 Then
objItem.GetStringValue HKLM, strKey & strSubkey, strEntry1b, strValue1
End If
If strValue1 <> "" Then
objSoftware.Add strValue1, strValue1
End If
If strValue1 Like "*.NET F*" Then
ActiveSheet.Range("B" & QueryStart & "").Value = "" & strValue1 & ""
QueryStart = QueryStart + 1
ElseIf strValue1 Like "MSXML*" Then
ActiveSheet.Range("B" & QueryStart & "").Value = "" & strValue1 & ""
QueryStart = QueryStart + 1
End If
Next
QueryStart = QueryStart + 1
StopSort = QueryStart
'MsgBox "Stop Value " & StopSort
' Sort retrieved software values
ActiveSheet.Sort.SortFields.Clear
ActiveSheet.Sort.SortFields.Add Key:= _
Range("B" & StartSort & ""), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:= _
xlSortTextAsNumbers
With ActiveSheet.Sort
.SetRange Range("B" & StartSort & ":B" & StopSort & "")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
'Remove Duplicates
Set Rng = Range("A" & StartSort, "B" & StopSort)
For I = Rng.Rows.Count To 2 Step -1
If Rng.Cells(I, 2) = Rng.Cells(I - 1, 2) Then
If Rng.Cells(I - 1, 1) <> "" Then
Rng.Cells(I, 1) = Rng.Cells(I - 1, 1)
End If
Rng.Rows(I - 1).Delete Shift:=xlShiftUp
End If
Next I
Bookmarks