My Problem:
I have made a For Each loop, which Loops through 2 different columns in the same sheet.
This loop copies the desired columns, and the unique values.
Althought the macro works, it will paste a wrong date.
How it pastes a wrong date, is specified under the section "Goal:".
My Table:
| Date | ColB | Amount | Date | ColG | Amount |
| 02-08-2018 | V584753 | 500 | 02-08-2018 | V584753 | -500 |
| 11-08-2018 | 486542 | 1.000 | 21-08-2018 | 439857 | -30.547 |
| 21-08-2018 | 439857 | 30.547 | 31-08-2018 | V587742 | -1.059 |
My Code:
Sub PasteCellsWithoutMatch()
Dim ColB As Range, ColG As Range, c As Range
Dim Wf As WorksheetFunction
Set Wf = WorksheetFunction
Dim vR() As Variant
Dim k As Long, j As Integer
For Each c In ColB.Cells
If Not IsEmpty(c) Then
With Wf
n = .CountIfs(ColG, c)
If n = 0 Then
k = k + 1
ReDim Preserve vR(1 To 3, 1 To k)
For j = 1 To 3
vR(j, k) = c.Offset(0, j - 2)
Next j
End If
End With
End If
Next
Sheet("Match").Range("A1").Resize(k, 3) = Wf.Transpose(vR)
Goal:
What I mean by "pasting the wrong date", the code will swaps the "dd-mm-yyyy" to "mm-dd-yyyy" whenever the first value is below 12.
Meaning that: 02-08-2018
Becomes: 08-02-2018
Whereas: 13-08-2018
Remains: 13-08-2018
How can I correct this error?
If there is any correction to it.
Thank you in advance, for your help.
