ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Change variable value of -1 to 1 (https://www.excelbanter.com/excel-programming/393102-change-variable-value-1-1-a.html)

Les Stout[_2_]

Change variable value of -1 to 1
 
Hello all, could somebody please tell me how to do the above in my code,
i am subtracting two dates and get a - value and would like to remove
the minus. My variable is long.



Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

Bob Phillips

Change variable value of -1 to 1
 
myVar = Abs(myVar)

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"Les Stout" wrote in message
...
Hello all, could somebody please tell me how to do the above in my code,
i am subtracting two dates and get a - value and would like to remove
the minus. My variable is long.



Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***




Chip Pearson

Change variable value of -1 to 1
 
Just multiply the value by -1 to switch signs:

V = V * -1

To ensure it is always negative, use

V = Abs(V) * -1


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)

"Les Stout" wrote in message
...
Hello all, could somebody please tell me how to do the above in my code,
i am subtracting two dates and get a - value and would like to remove
the minus. My variable is long.



Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***



Mike H

Change variable value of -1 to 1
 
Try

x = -1
x = Abs(x)

Mike

"Les Stout" wrote:

Hello all, could somebody please tell me how to do the above in my code,
i am subtracting two dates and get a - value and would like to remove
the minus. My variable is long.



Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***


Les Stout[_2_]

Change variable value of -1 to 1
 
I have solved it with the following thanks you...

dteDiff = Abs(dteDiff)

Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***

Les Stout[_2_]

Change variable value of -1 to 1
 
Thank you all for the input, much appreciated... :0)

Best regards,

Les Stout

*** Sent via Developersdex http://www.developersdex.com ***


All times are GMT +1. The time now is 08:53 AM.

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