Sub Main()
Dim c As Range
For Each c In [G8:H8]
If c > 0 Then c = c * -1
Next c
End Sub
Sub Main()
[G8:H8] = [IF({1},-ABS(G8:H8))]
End Sub
Is the IF function necessary?Here is another macro (a one-liner) that will also do what you want...
Code:Sub Main() [G8:H8] = [IF({1},-ABS(G8:H8))] End Sub
Sub Main()
[G8:H8] = [-ABS(G8:H8)]
End Sub
Is the IF function necessary?
This seems to work:
Code:Sub Main() [G8:H8] = [-ABS(G8:H8)] End Sub
Yes, it is necessary. Without it, if you put two different numbers in G8 and H8, the number in G8 ends up in both cells.
Weird... when I do the same thing, I get -36 in both cells.Hi Rick, I put 36 in G8 and 27 in H8 and got -36 and -27 respectively in the cells with the code by footoo Can you elaborate on when you get the same number in each cell.