Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Quick way to change negative #s to positive
Alot of times at work I need to take a column of numbers and change them to
either postive or negative numbers. I would like to be able to select the cells I want then click a button to change the signs of all the cells I selected. Is there such a button, like a +/- button?? If not is the fastest way to do this I can find is to select the cells, hit ctrl H and replace the - with blank. |
#2
|
|||
|
|||
I'm not sure if you want to reverse the sign of each number, or simply
convert all numbers to say, positive, even if some already are positive. This gives you 3 options: Sub ChangeSign() Dim cell As Range Dim rng As Range Dim iChoice As Integer Dim strMsg As String On Error GoTo NoRangeFound Set rng = Selection.SpecialCells(xlCellTypeConstants, 1) strMsg = "Type in 1 to convert to all pos., 2 for all neg., or 3 " & _ "to reverse the sign of each value." iChoice = Application.InputBox(strMsg, , , , , , , 1) If iChoice < 1 And iChoice < 2 And iChoice < 3 Then MsgBox "Not a valid number." Exit Sub End If For Each cell In rng With cell If iChoice = 1 And .Value < 0 Or _ iChoice = 2 And .Value 0 Or _ iChoice = 3 Then .Value = .Value * -1 End If End With Next Exit Sub NoRangeFound: MsgBox "No numbers found in range!" End Sub --- HTH Jason Atlanta, GA "Nih" wrote: Alot of times at work I need to take a column of numbers and change them to either postive or negative numbers. I would like to be able to select the cells I want then click a button to change the signs of all the cells I selected. Is there such a button, like a +/- button?? If not is the fastest way to do this I can find is to select the cells, hit ctrl H and replace the - with blank. |
#3
|
|||
|
|||
how about
Sub replaceminuw() Selection.Replace What:="-", Replacement:="", LookAt:=xlPart End Sub -- Don Guillett SalesAid Software "Nih" wrote in message ... Alot of times at work I need to take a column of numbers and change them to either postive or negative numbers. I would like to be able to select the cells I want then click a button to change the signs of all the cells I selected. Is there such a button, like a +/- button?? If not is the fastest way to do this I can find is to select the cells, hit ctrl H and replace the - with blank. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Finding negative and positive diffrence | Excel Worksheet Functions | |||
how do I rank negative and positive numbers? | Excel Worksheet Functions | |||
How can I change positive numbers to negative, i.e. change 50 to - | Excel Discussion (Misc queries) | |||
switching values from positive to negative | Excel Worksheet Functions | |||
highlighting positive or negative change | Excel Discussion (Misc queries) |