Negative to Positive

stumps

New Member
Joined
Jan 26, 2018
Messages
22
Hi Forum

I would like to change a few cells that appear as negative numbers to positive numbers.
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
A poor man's method:

In B2 enter and copy down:

=IF(A2<0,-A2,A2)

Copy the B-cells, select the A-cell, run Paste Special >> Values. Then delete B.
 
Upvote 0
I would like to change a few cells that appear as negative numbers to positive numbers.
If you mean you want to change them within the cells they currently are in, then select column or columns that contain the cells you want to change, then press CTRL+H to bring up the Replace dialog box, put a minus sign in the "Find what" field and leave the "Replace with" field empty, press the "Options>>" button and make sure the checkbox labeled "Match entire cell contents" is not checked, then click the "Replace All" button.
 
Upvote 0
=IF(A2<0,-A2,A2)

Or simply =ABS(A2) .

But IMHO, "stumps's" request is unclear. For starters, does column A (or whatever) contain constants or formulas? Does "stump" merely want to change how the values "appear"?
 
Upvote 0
Since I am learning VBA, I was trying to make a macro to convert all the negative number into positive numbers but due to some reason it doesn't work. The VBA seems to reject my IF statements.

Experts' assistance required.

Code:
Sub positive()

Dim r As Range
Dim c As Integer


Set r = Selection


[COLOR=#ff0000]    For Each c In r[/COLOR]
[COLOR=#ff0000]        If c.value < 0[/COLOR]
        Then c.value =  c * -1
        Else
        x
    End If
    Next


End Sub
 
Upvote 0
Since I am learning VBA, I was trying to make a macro to convert all the negative number into positive numbers but due to some reason it doesn't work. The VBA seems to reject my IF statements.

Experts' assistance required.

Code:
Sub positive()

Dim r As Range
Dim c As Integer


Set r = Selection


[COLOR=#ff0000]    For Each c In r[/COLOR]
[COLOR=#ff0000]        If c.value < 0[/COLOR]
        Then c.value =  c * -1
        Else
        x
    End If
    Next


End Sub

What is x? Shouldn't that be c?
 
Upvote 0
aladin, thanks for highlighting that typo error. however, the concern is with the highlighted line. The code gives error there on the red lines
 
Upvote 0

Forum statistics

Threads
1,223,214
Messages
6,170,771
Members
452,353
Latest member
strainu

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top