If a cell equals then macro
hi
try this...
Sub neg()
Dim r As Range
Dim rd As Range
Set r = Range("H2")
Do While Not IsEmpty(r)
Set rd = r.Offset(1, 0)
If r.Offset(0, -1) = "c" Then
r.Value = -r.Value
End If
Set r = rd
Loop
End Sub
regards
FSt1
"transferxxx" wrote:
I have a table with letters "C" or "D" in column G starting G2 & numbers in
column H. I would like the number in a cell to be negative if cell next to it
in column G = "c"
This would apply to all numbers in column starting from H2
The macro below has to be corrected
Sub neg()
If ActiveCell.Offset(0, -1) = "c" Then
ActiveCell.Value = -ActiveCell.Value
End If
End Sub
Pls help
|