Can someone please help me write a macro that will change the sign of the actively selected cells, even if a formula is in them already?
This works well for hardcoded figures:
But, if applied to a formula, it will hardcode it, which I'm trying to avoid.
I had the idea of using something that perhaps inserts "=-" at the beginning of all actively selected cells and then would toggle back on a second run of the code and remove the negative, but need some help writing this / not sure if it is the best way.
Please let me know if you have any ideas / can help here. Thanks so much!
This works well for hardcoded figures:
Code:
Sub ConvertValues()
Dim rng As Range
Dim area As Range
Dim c As Range
Set rng = Selection
For Each area In rng.Areas
For Each c In area.Cells
c.Value = c.Value * (-1)
Next c
Next area
End Sub
But, if applied to a formula, it will hardcode it, which I'm trying to avoid.
I had the idea of using something that perhaps inserts "=-" at the beginning of all actively selected cells and then would toggle back on a second run of the code and remove the negative, but need some help writing this / not sure if it is the best way.
Please let me know if you have any ideas / can help here. Thanks so much!