I need some help with using a scriptingdictionary on a filtered range. Essentially,I’m trying to identify instances on the Variables tab (columns A & B), thatalso exist on the Holds tab (columns K & G).Where they box exist, I want the values fromcolumns C & D on the Variables tab, to populate into columns R & S onthe Holds tab.I’ve verified that thereare dozens of matches that should be being identified, however, as I stepthrough the code, there aren’t any updates being made at all.
Thoughts on where I’ve gone wrong on this?
Thoughts on where I’ve gone wrong on this?
Code:
Sub IdentifyOwners()[/COLOR][/FONT]
[FONT=Tahoma][COLOR=#000000]Application.ScreenUpdating = False
Application.DisplayAlerts = False
Application.EnableEvents = False[/COLOR][/FONT]
[FONT=Tahoma][COLOR=#000000]Dim d As Workbook
Dim dH, dV As Worksheet
Dim Rng As Range
Dim RngList As Object[/COLOR][/FONT]
[FONT=Tahoma][COLOR=#000000]Set d = ThisWorkbook
Set dH = d.Sheets("Holds")
Set dV = d.Sheets("Variables")
Set RngList = CreateObject("Scripting.Dictionary")[/COLOR][/FONT]
[FONT=Tahoma][COLOR=#000000]SortAscending dH, "R1"[/COLOR][/FONT]
[FONT=Tahoma][COLOR=#000000]With dH
On Error Resume Next
.UsedRange.AutoFilter Field:=18, Criteria1:=""
End With[/COLOR][/FONT]
[FONT=Tahoma][COLOR=#000000]dLR1 = dH.Range("B" & Rows.Count).End(xlUp).Row[/COLOR][/FONT]
[FONT=Tahoma][COLOR=#000000]If dLR1 > 1 Then
On Error Resume Next
For Each Rng In dV.Range("A2", dV.Range("A" & dV.Rows.Count).End(xlUp))
If Not RngList.Exists(Rng.Value & "|" & Rng.Offset(0, 1)) Then
RngList.Add (Rng.Value & "|" & Rng.Offset(0, 1)), Rng
End If
Next
For Each Rng In dH.Range("K2", dH.Range("K" & dH.Rows.Count).End(xlUp))
If RngList.Exists(Rng.Value & "|" & Rng.Offset(0, -4)) Then
dH.Range("R" & Rng.Row).Value = sV.Range("C" & Rng.Row).Value
dH.Range("S" & Rng.Row).Value = sV.Range("D" & Rng.Row).Value
End If
Next
End If
Application.ScreenUpdating = True
Application.DisplayAlerts = True
Application.EnableEvents = True[/COLOR][/FONT]
[FONT=Tahoma][COLOR=#000000]End Sub[/COLOR][/FONT]