Question : Formula for changing positive to negative

When I try to use the formula:

IF(B6>0,-B6,0) or any variants, I get a circular reference error.  The error is obvious, but the syntax for converting the number from a positive to a negative value eludes me.

What I really want is for my client to enter a number into the cell and have it automatically convert to a negative value, and it has occurred to me that a formula won't examine the value of the entry thus producing the circular reference.

Has anyone figured out an elegant way to do this?

My solutions so far:  Run a timer that tests the value of the cells every few seconds to see if there is a positive number there

Place button on the sheet so the macro pre-edits before calculating.

Presumably, I'm going to deliver this tomorrow morning....

Thanks for your help.

Mike Burke

Answer : Formula for changing positive to negative

Hi meburke,
The following macro watches column A and makes all positive values negative. The sub goes in the code pane for the worksheet being watched.

To paste the sub in the code pane for a worksheet, right-click the
worksheet's sheet tab. Then choose View Code from the pop-up. Paste the
code there, then ALT + F11 to return to the spreadsheet.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim cel As Range
If Intersect(Target, Range("A:A")) 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

Cheers!
Random Solutions  
 
programming4us programming4us