ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Negative Numbers (https://www.excelbanter.com/excel-programming/298922-negative-numbers.html)

alexm999[_77_]

Negative Numbers
 
Whats the VB code to make numbers negative?
I need the following column negative:
AP9:AP3

--
Message posted from http://www.ExcelForum.com


Frank Kabel

Negative Numbers
 
Hi
one way: try something like the following
sub foo()
dim rng as range
dim cell as range
set rng = activesheet.range("AP9:AP39)
for each cell in rng
if cell.value0 then
cell.value = -cell.value
end if
next
end sub

--
Regards
Frank Kabel
Frankfurt, Germany


Whats the VB code to make numbers negative?
I need the following column negative:
AP9:AP39


---
Message posted from http://www.ExcelForum.com/


Chip Pearson

Negative Numbers
 
Try something like

Dim Rng As Range
For Each Rng In Range("AP9:AP39")
Rng.Value = Rng.Value * -1
Next Rng


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



"alexm999 " wrote in
message ...
Whats the VB code to make numbers negative?
I need the following column negative:
AP9:AP39


---
Message posted from http://www.ExcelForum.com/




alexm999[_79_]

Negative Numbers
 
Thanks, both worked

--
Message posted from http://www.ExcelForum.com



All times are GMT +1. The time now is 10:30 AM.

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