Putting this all together is giving me a migraine. I’m sure this will be easy enough for most of you.
When I download activity from my checking account it arrives with five columns and x number of rows.
I put this data into a budget I created. I want to create a macro that takes the download and formats as follows
Column 1: NumberFormat = “MM/DD/YYYY”
Column 2: = (Determined by Column 4) IF value in column 4 <0,”DEBIT”,”CREDIT”
Column 3. Autofit
Column 5. Deleted
Column 4 : NumberFormat = “$#,##0.00;[Red]$#,##0.00”
Date Transaction Name Memo Amount
05/13/2024 YADA YADA YADA YADA YADA YADA 98.00
05/13/2024 YADA YADA YADA YADA YADA YADA 98.00
05/13/2024 YADA YADA YADA YADA YADA YADA 98.00
05/13/2024 YADA YADA YADA YADA YADA YADA 98.00
05/14/2024 YADA YADA YADA YADA YADA YADA 98.00
05/14/2024 YADA YADA YADA YADA YADA YADA 98.00
05/15/2024 YADA YADA YADA YADA YADA YADA 98.00
05/15/2024 YADA YADA YADA YADA YADA YADA 98.00
I tried the following but the “if” statement column 2 is wrong I guess since it doesn’t work
Option Explicit
Sub BankFormat() ‘
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long
Set ws = ThisWorkbook.Sheets("Sheet1")
Columns(1).NumberFormat = "MM/DD/YYYY"
Columns(4).NumberFormat = "$#,##0.00;[Red]$#,##0.00"
' Find the last row in column D (fourth column)
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
For i = 2 To lastRow
ws.Cells(i, 2).Value = IIf(ws.Cells(i, 4).Value < 0, "Credit", "Debit")
ws.Cells(i, 4).NumberFormat = "$#,##0.00;[Red]$#,##0.00"
Next i
End Sub
Denis Wryn is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.