View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson[_3_] Dave Peterson[_3_] is offline
external usenet poster
 
Posts: 2,824
Default Convert -ve numbers to +ve

select your range and then run this:

Option Explicit
Sub testme01()
Dim myCell As Range
Dim myRange As Range

On Error Resume Next
Set myRange = Intersect(Selection, _
Selection.Cells.SpecialCells(xlCellTypeConstants, xlNumbers))
On Error GoTo 0

If myRange Is Nothing Then
MsgBox "Select a range with number values"
Exit Sub
End If

For Each myCell In myRange.Cells
If myCell.Value < 0 Then
myCell.Value = -myCell.Value
End If
Next myCell

End Sub

And if you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

ali wrote:

I often have to work with sheets that contain awkward negative numbers
and it would make my life much easier if i could use a macro that would
search a column and convert any negative numbers into positive
numbers.

Can anyone help my with how i can do this please?

Alternatively if anyone can tell me how to convert positive numbers to
negative that would be equally useful.

Many thanks

------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/


--

Dave Peterson