I've modified my code to make it automatic and correct a omisson:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim I As Long
Dim last As Long
Dim cell As Range
Dim isect As Range
Dim CreditDebit As Range
Set CreditDebit = Range("A1:A100")
Set isect = Application.Intersect(Target, CreditDebit)
If Not isect Is Nothing Then
CreditDebit.Font.Strikethrough = False
last = CreditDebit.Row + CreditDebit.Count - 1
For Each cell In CreditDebit
With cell
If .Font.Strikethrough = False Then
I = 1
Do
If .Offset(I, 0) = -cell And .Offset(I, 0).Font.Strikethrough = False Then
.Font.Strikethrough = True
.Offset(I, 0).Font.Strikethrough = True
Exit Do
End If
I = I + 1
Loop Until .Offset(I, 0).Row > last
End If
End With
Next cell
End If
End Sub
You should change the line Set CreditDebit = Range("A1:A100") to match the range where your data is.
To use this code press Alt+F11, in the VBA project window at the top left locate your file and then the sheet you where you debits and credit are. Double-click that sheet to expose the coresponding code sheet on the right. Copy and past the above code
into that sheet.
If this answer solves your problem, please check, Mark as Answered. If this answer helps, please click theVote as Helpful button. Cheers Shane Devenshire
when i run the code or write down any numbers to run the code i saw that in VBA highlighted the line below and pop up msg (run time error 13 type mismatched) i already uses office 13
If .Offset(I, 0) = -cell And .Offset(I, 0).Font.Strikethrough = False Then