joelle
09-26-2005, 11:06 AM
Hello Everyone,
I got great help from experts in this board for the codes below. They work beautifully.
However, it was my poor memoire to forget to mention that I needed to group multiple field for "credit" (here, A1:A2) to a named range "credit" so that:
1. When people type in a number in one field or both field of the range, each number will turn to a negative value for the "Total" to calculate the credit correctly.
2. When people add lines to my ws, the codes still work properly.
Please any edition is very much appreciated.
Nee
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If IsNumeric([a1]) Then [a1] = -Abs([a1])
If IsNumeric([a2]) Then [a2] = -Abs([a2])
Application.EnableEvents = True
End Sub
I got great help from experts in this board for the codes below. They work beautifully.
However, it was my poor memoire to forget to mention that I needed to group multiple field for "credit" (here, A1:A2) to a named range "credit" so that:
1. When people type in a number in one field or both field of the range, each number will turn to a negative value for the "Total" to calculate the credit correctly.
2. When people add lines to my ws, the codes still work properly.
Please any edition is very much appreciated.
Nee
Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
Application.EnableEvents = False
If IsNumeric([a1]) Then [a1] = -Abs([a1])
If IsNumeric([a2]) Then [a2] = -Abs([a2])
Application.EnableEvents = True
End Sub