Hi Team,
How to avoid #N/A and Blanks cells in Dictionary Keys.
Column A and B cells are keys after joining both the cells.
Column C are dictionary Items Date Columns.
Genuine Dictionary keys and Items shown in Column E and F.
Below is a Sample data expected output is in Column E and F.
Below is my attempted Code.
Thanks
mg
How to avoid #N/A and Blanks cells in Dictionary Keys.
Column A and B cells are keys after joining both the cells.
Column C are dictionary Items Date Columns.
Genuine Dictionary keys and Items shown in Column E and F.
Below is a Sample data expected output is in Column E and F.
Book6 | ||||||||
---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | |||
1 | Invoice | Receipt | Date | Genuine Dictionary Key | Genuine Dictionary Items | |||
2 | 1000 | R_1 | 30/04/2019 | 1000|R_1 | 30/04/2019 | |||
3 | 2000 | R_2 | 07/05/2019 | 2000|R_2 | 07/05/2019 | |||
4 | Not available | Not available | 11/05/2019 | 5000|300 | 11/01/2020 | |||
5 | Not available | Not available | 15/06/2019 | 6000|R_4 | 11/01/2020 | |||
6 | 3000 | #N/A | 05/08/2019 | |||||
7 | #N/A | #N/A | 05/08/2019 | |||||
8 | #N/A | 80000 | 05/08/2019 | |||||
9 | 4000 | 27/09/2019 | ||||||
10 | 14/12/2019 | |||||||
11 | 5000 | 300 | 11/01/2020 | |||||
12 | 6000 | R_4 | 11/01/2020 | |||||
Sheet1 |
Cell Formulas | ||
---|---|---|
Range | Formula | |
E2:E3 | E2 | =A2&"|"&B2 |
E4:E5 | E4 | =A11&"|"&B11 |
Below is my attempted Code.
VBA Code:
Option Explicit
Sub Dictionary_Key_issue()
Dim arr As Variant
Dim dict As New Scripting.Dictionary
arr = Range("A2:C12").Value
Dim i As Long
Dim skey As String
'Store into Dictionary
With dict
For i = 2 To 12
skey = arr(i, 1) & "!" & arr(i, 2) 'avoid #N/A , Blanks here
If Not .Exists(skey) Then
.Add skey, arr(i, 3)
End If
Next i
End With
End Sub
Thanks
mg