How to write macro that would match the first sheet's date with the other sheet's date then counter checking the amount (if date and amount are the same) then it would copy the whole data from the 2nd sheet beside the first sheet data (that had matched)
I wrote something that goes like this:
Sub MatchFundTransferData()
Dim Found As Range, FirstFound As String, rngDate As Range, counter As Long
Dim ws1 As Worksheet, ws2 As Worksheet
Set ws1 = Sheets("Sheet1") 'Destination worksheet
Set ws2 = Sheets("Sheet2") 'Source worksheet
Application.ScreenUpdating = False
For Each rngDate In ws1.Range("A:A").SpecialCells(xlCellTypeConstants, xlNumbers)
If IsEmpty(rngDate.Offset(, 5)) Then
Set Found = ws2.Range("A:A").Find(What:="Date" & rngDate.Value, _
LookIn:=xlValues, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Found Is Nothing Then
FirstFound = Found.Address
Do
If Found.Offset(, 5).Value = rngDate.Offset(, 1).Value Then
Found.Offset(, -2).Resize(, 8).Cut Destination:=rngDate.Offset(, 5)
counter = counter + 1
Exit Do
End If
Set Found = ws2.Range("A:A").FindNext(After:=Found)
Loop Until Found.Address = FirstFound
End If
End If
Next rngDate
Application.ScreenUpdating = True
MsgBox counter & " Data Had Matched", vbInformation, "Matching Check Data Complete"
End Sub
but i think it's not working..
Bookmarks