samsilverman
Board Regular
- Joined
- Nov 9, 2009
- Messages
- 176
I am using Excel 2007.
With the help of this forum, I have the following code in a worksheet VB so that anytime I type a number in a column, it shows up as a negative value.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cel As Range
If Intersect(Target, Range("I:J")) Is Nothing Then Exit Sub
On Error Resume Next
Application.EnableEvents = False
For Each cel In Target.Cells
If cel > 0 Then cel = -cel
Next cel
Application.EnableEvents = True
End Sub
I have a question. How can I expand this to do just the opposite in other select columns. In other words, change any number in "F:G" to a positive number. Is it possible to have a code do both of these actions?
With the help of this forum, I have the following code in a worksheet VB so that anytime I type a number in a column, it shows up as a negative value.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim cel As Range
If Intersect(Target, Range("I:J")) Is Nothing Then Exit Sub
On Error Resume Next
Application.EnableEvents = False
For Each cel In Target.Cells
If cel > 0 Then cel = -cel
Next cel
Application.EnableEvents = True
End Sub
I have a question. How can I expand this to do just the opposite in other select columns. In other words, change any number in "F:G" to a positive number. Is it possible to have a code do both of these actions?
Last edited: