Hi jscalem
Try this...
Option Explicit
Sub Populate_Chargebacks()
Dim ws As Worksheet
Dim ws1 As Worksheet
Dim LR As Long
Dim Rng As Range
Dim Rng1 As Range
Dim cel As Range
Dim c As Range
Set ws = Sheets("Register")
Set ws1 = Sheets("Chargebacks")
Application.ScreenUpdating = False
With ws
LR = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _
SearchDirection:=xlPrevious).Row
If Not .AutoFilterMode Then
.Rows("1:1").AutoFilter
End If
.Range("A1:T" & LR).AutoFilter Field:=8, Criteria1:=Array( _
"NSF", "REFER", "CLOSE", "STOP"), Operator:=xlFilterValues
.Range("A1:T" & LR).AutoFilter Field:=5, Criteria1:="6"
.Range("A1:T" & LR).AutoFilter Field:=1, Criteria1:= _
"<>Z99999", Operator:=xlAnd
If Not .AutoFilter.Range.Columns(1).SpecialCells(xlCellTypeVisible).Count - 1 = 0 Then
Set Rng = .Range(.Cells(2, "D"), .Cells(LR, "D")).SpecialCells(xlCellTypeVisible)
Set Rng1 = ws1.Columns(1)
For Each cel In Rng
Set c = Rng1.Find(Format(cel.Value, "d-mmm-yy"), , xlValues, xlWhole, xlByRows, xlNext, False)
If Not c Is Nothing Then
ws1.Cells(c.Row, "F").Value = ws1.Cells(c.Row, "F").Value + 1
ws1.Cells(c.Row, "G").Value = ws1.Cells(c.Row, "G").Value + cel.Offset(0, 2).Value
End If
Next cel
Else: MsgBox "No records found"
End If
.AutoFilterMode = False
End With
Application.ScreenUpdating = True
End Sub
Bookmarks