Scripting Dictionary on Filtered Range, Not Writing Back

reberryjr

Well-known Member
Joined
Mar 16, 2017
Messages
714
Office Version
  1. 365
Platform
  1. Windows
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?

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]

 
but we have (,2) which would be changing it by 2 columns
That quite right :)

So
Code:
Range("R2").resize(,2)
Is the same as
Code:
Range("R2:S2")
 
Upvote 0

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,223,276
Messages
6,171,140
Members
452,381
Latest member
Nova88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top