praveenkammar
New Member
- Joined
- Aug 18, 2010
- Messages
- 14
hi all,
I have column A with some amounts with negative and positive values, column B with alphanumeric values, i have the below code which highlights rows if the negative and positive value sums up to 0. but I need a code which highlights rows if column B is duplicate and sum in column A is 0.
A B
10.1 29ab287
12 37gj238
12 487jhj2897
10.1 29ab287
42 46872
Please help!!!!!!!!
I have column A with some amounts with negative and positive values, column B with alphanumeric values, i have the below code which highlights rows if the negative and positive value sums up to 0. but I need a code which highlights rows if column B is duplicate and sum in column A is 0.
A B
10.1 29ab287
12 37gj238
12 487jhj2897
10.1 29ab287
42 46872
Please help!!!!!!!!
HTML:
Sub MG07Jul24()
Dim rng As Range
Dim Dn As Range
Set rng = Range(Range("B1"), Range("B" & Rows.Count).End(xlUp))
With CreateObject("scripting.dictionary")
.CompareMode = vbTextCompare
For Each Dn In rng
If Not .Exists(Abs(Dn.Value)) Then
.Add Abs(Dn.Value), Dn
Else
If .Item(Abs(Dn.Value)).Count = 1 And .Item(Abs(Dn.Value)) + Dn.Value = 0 Then
Set .Item(Abs(Dn.Value)) = Union(.Item(Abs(Dn.Value)), Dn)
'.Item(Abs(Dn.Value)).Font.ColorIndex = 3
.Item(Abs(Dn.Value)).Interior.ColorIndex = 6
End If
End If
Next
End With
End Sub