Pages

Wednesday, July 6, 2011

Show the positive values with Happy face and negative values with Sad face

if you want to show the positive values with the happy face and negative values with sad face. Snapshot below -



Here is the code-

Sub happy_sad_smiley()
Dim i As Long

For i = 2 To Sheets(1).Range("a65356").End(xlUp).Row

' why i have taken J and L in values and font name Wingdings 3 plz check the table in attached workbook

If Sheets(1).Range("a" & i).Value > 0 Then
Sheets(1).Range("c" & i).Value = "J"
Sheets(1).Range("c" & i).HorizontalAlignment = xlCenter
Sheets(1).Range("c" & i).Font.Color = vbGreen
Sheets(1).Range("c" & i).Font.Name = "Wingdings"


ElseIf Sheets(1).Range("a" & i).Value <> "" Then

Sheets(1).Range("c" & i).Value = "L"
Sheets(1).Range("c" & i).Font.Name = "Wingdings"
Sheets(1).Range("c" & i).Font.Color = vbRed
Sheets(1).Range("c" & i).HorizontalAlignment = xlCenter
End If
Next i

End Sub


Excel Macro File
http://www.filefactory.com/file/cc35d0f/n/diplay_postive_and_negative_values_with_symbols.xlsm

No comments:

Post a Comment