Hi!
I use the code below to store ID's and the corresponding email addresses. Now I need to add a name too and I realized that the Dictionary object can only have one value. I tried adapting my code using a Class Module, but my VBA knowledge is weak. Could someone please help me out a little?
Thank you very much!
I use the code below to store ID's and the corresponding email addresses. Now I need to add a name too and I realized that the Dictionary object can only have one value. I tried adapting my code using a Class Module, but my VBA knowledge is weak. Could someone please help me out a little?
Account # | Name | |
123 | foo@bar.co | Foo Bar |
VBA Code:
Dim wb As Workbook, ws As Worksheet
Dim iLastRow As Long, i As Long
Dim dictID As Object, ID, addr As String
Set dictID = CreateObject("Scripting.Dictionary")
' get list of IDS
Set wb = ThisWorkbook
Set ws = wb.Sheets(WS_ID)
iLastRow = ws.Cells(Rows.Count, "A").End(xlUp).Row
For i = 2 To iLastRow
ID = Trim(ws.Cells(i, "A"))
addr = Trim(ws.Cells(i, "B"))
If dictID.exists(ID) Then
MsgBox ID & " is duplicated", vbCritical, "Duplicate ID"
Exit Sub
ElseIf InStr(1, addr, "@") > 0 Then
dictID.Add ID, addr
End If
Next
Thank you very much!