I'm trying to leverage a scripting dictionary to copy a value from 1 worksheet (mD) to another worksheet (mI); where both worksheets have common values. Simple example: If on worksheet mI, the value in column A and the value in column L = the value in column A and the value in column H, then update column Q on the mI worksheet with the value from column J on the mD worksheet. I was attempting the scripting dictionary based off of some advice I've received previously on this site, but I'm getting a Next without For error. I'm not sure why, as the code I was given previously is built almost exactly the same way.
VBA Code:
Sub IQR_Calcs()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Dim m As Workbook
Dim mI As Worksheet, mM As Worksheet, mD As Worksheet, mO As Worksheet, mP As Worksheet, mV As Worksheet
Dim mILR As Long, mMLR As Long, mDLR As Long, mOLR As Long, mPLR As Long, mVLR As Long, i As Long
Dim Rng As Range
Dim Dic As Object
Set m = ThisWorkbook
Set mI = m.Sheets("CC_IQR")
Set mM = m.Sheets("CC_MC")
Set mD = m.Sheets("CC_MD")
Set mO = m.Sheets("ORC_PAR")
Set mP = m.Sheets("PRF")
Set mV = m.Sheets("Variables")
mILR = mI.Range("A" & Rows.Count).End(xlUp).Row
mMLR = mM.Range("A" & Rows.Count).End(xlUp).Row
mDLR = mD.Range("A" & Rows.Count).End(xlUp).Row
mOLR = mO.Range("A" & Rows.Count).End(xlUp).Row
mPLR = mP.Range("A" & Rows.Count).End(xlUp).Row
mVLR = mV.Range("A" & Rows.Count).End(xlUp).Row
Set Dic = CreateObject("Scripting.Dictionary")
For Each Rng In mI.Range("A2", mI.Range("A" & mI.Rows.Count).End(xlUp))
If Not Dic.Exists(Rng.Value & Rng.Offset(0, 11)) Then
Dic.Add Rng.Value & Rng.Offset(0, 11), Nothing
End If
Next Rng
For Each Rng In mD.Range("A2", mD.Range("A" & mD.Rows.Count).End(xlUp))
If Dic.Exists(Rng.Value & Rng.Offset(0, 11)) Then
mD.Range("I" & Rng.Row).Copy
mI.Range("Q" & Rng.Row).PasteSpecial xlPasteValues
Else
If Not Dic.Exists(Rng.Value & Rng.Offset(0, 11)) Then
mI.Range("Q" & Rng.Row) = "Review"
End If
Next Rng
Dic.RemoveAll
Application.ScreenUpdating = True
Application.DisplayAlerts = True
End Sub