commonproblems
New Member
- Joined
- Apr 25, 2018
- Messages
- 7
Hi all,
I'm trying to write code that allows me to make negative numbers red and positive numbers black for a highlighted range of cells.
it seems to work based on the first cell, so if the first cell is negative all numbers go red and if the first number is positive all numbers go black.
I've pasted the code below, if someone would be able to suggest a fix. Thank you
Sub Decimalworkswith2decimalplaces()
'
' Decimalworkswith2decimalplaces Macro
' decimal works with 2 decimal places
'
Selection.NumberFormat = "_(* #,##0.00_);_(* (#,##0.00);_(* """"-""""??_);_(@_)"
If ActiveCell.Value < 0 Then
With Selection.Font
.Color = 255
End With
End If
End Sub
I'm trying to write code that allows me to make negative numbers red and positive numbers black for a highlighted range of cells.
it seems to work based on the first cell, so if the first cell is negative all numbers go red and if the first number is positive all numbers go black.
I've pasted the code below, if someone would be able to suggest a fix. Thank you
Sub Decimalworkswith2decimalplaces()
'
' Decimalworkswith2decimalplaces Macro
' decimal works with 2 decimal places
'
Selection.NumberFormat = "_(* #,##0.00_);_(* (#,##0.00);_(* """"-""""??_);_(@_)"
If ActiveCell.Value < 0 Then
With Selection.Font
.Color = 255
End With
End If
End Sub