title: VBA Dictionary to search, match, and paste: Unknown Error
body: <p>Ok, so I pulled this code from <a href="https://stackoverflow.com/questions/31071004/vba-find-value-then-paste-another-into-different-cell-in-another-column">here</a>,  and have been trying to adapt it with little success. I may simply be misunderstanding the original or am missing some other fundamental flaw (like perhaps the code was written for an older iteration of excel). </p>
  
  <p>I have a Master Sheet (2018) with a lot of different rows with different tasks assigned to an inspector. Each task has a number in column G that is unique, and an inspector can have more than one task--but no task has more than one inspector. Column G is unique--the numbers do not repeat. Each inspector has his/her own sheet that is updated using a different excel--inspector sheets are formatted exactly as the master sheet is, all columns are the same. The inspector will put in the date, in their own sheet, a task is completed (date goes in Column R) and I'm trying to use this code so that when an inspector completes a task and put in the date, he clicks a button and that date is copied to column R in the master sheet in the correct row that matches the correct task number.</p>
  
  <p>Like so:
  <a href="https://i.stack.imgur.com/gGusJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gGusJ.png" alt="copyPaste"></a></p>
  
  <p>I'm using this code to work around using a formula like index match or vlookup (far too much data and the workbook is designed to be used by individuals who do not know how to drag down a formula when new records are added).</p>
  
  <pre><code>Sub dates()
  
  Application.ScreenUpdating = False
  
  Dim AVals As New Dictionary
  Dim i As Long, j As Long, lastRow1 As Long, lastRow2 As Long
  Dim sh_insp, sh_2018 As Worksheet
  Dim MyName As String
  
  Set sh_insp = Activesheet
  Set sh_2018 = Sheets("2018")
  
  With sh_insp
      lastRow1 = .Range("A:A").Rows.Count 'last row in spreadsheet
      lastRow1 = .Cells(lastRow1, 7).End(xlUp).Row 'last used row in column G
      'load the AVal dict
      For j = 18 To lastRow1
          MyName = .Cells(j, 7).Value
          If Len(MyName) &gt; 0 Then AVals.Add MyName, .Cells(j, 7).Value
      Next j
  End With
  
  With sh_2018
      lastRow2 = .Range("A:A").Rows.Count
      lastRow2 = .Cells(lastRow2, 7).End(xlUp).Row 'last used row in column G
      For i = 18 To lastRow2
          MyName = .Cells(i, 7).Value
          If AVals.Exists(MyName) Then
              .Cells(i, 18).Value = AVals.Item(MyName)
          End If
       Next i
  End With
  Application.ScreenUpdating = True
  
  End Sub
  </code></pre>
  
  <p>I'm getting a 'User-defined type not defined' at the <code>Dim AVals as New Dictionary</code>   which prevents me from really even seeing if it works or not. Also, sometimes a task isn't assigned yet and you have tasks assigned but not completed. I don't want it to erase anyone's data only add data when a task number is matched. Does this make sense?</p>