I am doing some work which requires automating payment approval requests, the issue I am having is that there are two identifiers for the payment requests with multiple payments, So for example I wish to make 4 payments with the flag apple and 5 payments with the flag banana. The macro will need to look up all payments with the payment date of today and then determine whether or not this payment is for apple or banana. It will then copy all payments for today for both and paste them on another sheet.
Let's assume that The date identifier is on cell A2 on Source Data Sheet and the dates are in cells F4 to F2000 and the apple/banana flag is in G4 to G2000.
I want to take the value of the payment in cells H4 to H2000 and paste them on either Apples Payment tab or Banana Payment tab along with it's unique reference number in cells I4 to I2000.
I have attempted to use something else I have found on here but I am really struggling, could somebody please help me!
Sub Fruit()
Dim lastRow As Long
Dim lastTRow As Long 'Last Target Row
Dim tRow As Long 'Target Row
Dim source As String 'The source sheet
Dim target As String 'Variable target sheet
Dim tempVal As String 'Hold value of Source!B2
Dim ws As Worksheet
source = "Source Data"
lastRow = Sheets("Source Data").Range("D" & Rows.Count).End(xlUp).Row
For lRow = 3 To lastRow 'Loop through source sheet
tempVal = Sheets("Source Data").Cells(lRow, "D").Text
If Sheets("Source Data").Cells(lRow, "F").Value = tempVal Then
Sheets("Source Data").Cells(lRow, "I").Copy
lastTRow = Sheets("Banana").Range("C" & "70").End(xlUp).Row 'Get Last Row
tRow = lastTRow + 1 'Set new Row 1 after last
'tRow.Select.Paste
'Copy cells from one sheet to another loop columns
Sheets("Banana").Cells(tRow, "C").PasteSpecial
End If
Next lRow
End Sub
End Ifstatement at the end -- the beauty of correct indenting is that you notice these errors very quickly!