ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   MACRO: How to change cells to negative value (https://www.excelbanter.com/excel-programming/303584-macro-how-change-cells-negative-value.html)

Tony

MACRO: How to change cells to negative value
 
For something that seems so simple, I cannot come up with
a solution.

I want to run a macro that will change the contents of a
cell from a positive number to a negative number.

For example, if I have 1000 in A1, I will select A1 and
run a macro that will change its value to -1000.

Thanks in advance.

JWolf

MACRO: How to change cells to negative value
 
Sub simple()
activecell.value=activecell.value * -1
End Sub

Tony wrote:

For something that seems so simple, I cannot come up with
a solution.

I want to run a macro that will change the contents of a
cell from a positive number to a negative number.

For example, if I have 1000 in A1, I will select A1 and
run a macro that will change its value to -1000.

Thanks in advance.


JE McGimpsey

MACRO: How to change cells to negative value
 
Or,

Sub even_simpler()
ActiveCell.Value = -ActiveCell.Value
End Sub

If you *always* want a negative number:

Sub always_negative()
ActiveCell.Value = -Abs(ActiveCell.Value)
End Sub

In article ,
JWolf wrote:

Sub simple()
activecell.value=activecell.value * -1
End Sub

Tony wrote:

For something that seems so simple, I cannot come up with
a solution.

I want to run a macro that will change the contents of a
cell from a positive number to a negative number.

For example, if I have 1000 in A1, I will select A1 and
run a macro that will change its value to -1000.

Thanks in advance.



All times are GMT +1. The time now is 09:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com