This code works, however I am trying to reuse this code in another workbook. I thought it would be as simple as updating the range(s) but apparently not. Would anyone happen know what is causing this? Thank you!
Option Explicit
Sub Unique_Id()
Dim i As Long
Dim Ary As Variant
Ary = Range("J2", Range("J" & Rows.Count).End(xlUp).Offset(, 1)).Value2
With CreateObject("scripting.dictionary")
For i = 1 To UBound(Ary)
.Item(Ary(i, 1)) = .Item(Ary(i, 1)) + 1
Ary(i, 2) = Ary(i, 1) & "-" & .Item(Ary(i, 1))
Next i
End With
Range("K2").Resize(UBound(Ary)).Value = Application.Index(Ary, 0, 2) ' Run time error 13 Type mismatch
End Sub
Bookmarks