Converting all numbers to negative
James,
No, it isn't correct. The Me is not an allowed keyword in this context. And you left out the
looping.
Put this code into a regular codemodule:
Sub TryNow()
Dim myCell As Range
Dim myRng As Range
Set myRng = Range("J8:AA22")
For Each myCell In myRng
If IsNumeric(myCell.Value) And (Not IsEmpty(myCell)) Then
myCell.Value = -Abs(myCell.Value)
End If
Next myCell
End Sub
HTH,
Bernie
MS Excel MVP
"Please help James" wrote in message
...
Bernie, is this right?
Sub TryNow()
Dim myCell As Range
Dim myRng As Range
Set myRng = Me.Range("J8:AA22")
If IsNumeric(myCell.Value) And (Not IsEmpty(myCell)) Then
myCell.Value = -Abs(myCell.Value)
End If
Next myCell
End Sub
"Bernie Deitrick" wrote:
If you have numbers already in a range, select the range and run this macro
Sub TryNow()
Dim myCell As Range
For Each myCell In Selection
If IsNumeric(myCell.Value) And (Not IsEmpty(myCell)) Then
myCell.Value = -Abs(myCell.Value)
End If
Next myCell
End Sub
HTH,
Bernie
MS Excel MVP
"Please help James" wrote in message
...
Does anyone know how to create a code that would convert all numbers entered
into a range of cells into a negative number? -ABS Thanks!
|