Change Cell Color

meighkee

New Member
Joined
Sep 3, 2008
Messages
39
Greetings,

I am creating a spreadsheet, tracking my stock performance. I would like to have the cell color change automatically to red or green depending on whether the stock price went up or down. I am putting in an up or down arrow within the same cell as the stock price, using the Alt 24 or Alt 25 keys. Example: I have a cell whereby I enter an up arrow (↑), and then a number. If the cell has an up arrow, I'd like it to turn green. A down arrow - red. I hope this makes sense.

Appreciate any help.

Thank you.
 

Special-K99

Well-known Member
Joined
Nov 7, 2006
Messages
8,301
Normally I'd use CODE() to identify the ASCII character for u/down arrow.
Unfortuantely both characters result in a one character length code of 63.
So there's no way to determine whether the arrow is up or down.

Use Wingdings 3 font and the characters

È Ç

for down and up. Copy the characters to two blank cells, change the font for those cells to Wingdings 3, then just manually copy and paste the characters to whatever cells you want,
then this as conditional formatting

Select the range

Conditional Formatting
New Rule
Use a formula to determine...

=CHAR(199)
format as green

=CHAR(200)
format as red
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
30,213
Office Version
365
Platform
Windows
For the Up arrow use
=UNICODE(E3)=8593
and down arrow
=UNICODE(E3)=8595

Change the E3 too the first cell in the applies to range
 

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
16,038
Assuming you will be entering these values in column A of your sheet.
I suggest you use this script. if your stock goes up the cell color will turn green. If the stock price goes down the cell will turn red.

Enter stock price in column A
No need for arrows and pressing Keys

This is an auto sheet event script
Your Workbook must be Macro enabled
To install this code:
Right-click on the sheet tab
Select View Code from the pop-up context menu
Paste the code in the VBA edit window

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
'Modified  7/22/2019  11:12:44 AM  EDT
If Target.Cells.CountLarge > 1 Or IsEmpty(Target) Then Exit Sub
If Target.Column = 1 And Target.Row > 1 Then
    If Target.Value < Target.Offset(-1).Value Then Target.Interior.Color = vbRed
    If Target.Value > Target.Offset(-1).Value Then Target.Interior.Color = vbGreen
End If
End Sub
 

Forum statistics

Threads
1,077,795
Messages
5,336,374
Members
399,078
Latest member
johnk94

Some videos you may like

This Week's Hot Topics

Top