Change Cell Color

meighkee

New Member
Joined
Sep 3, 2008
Messages
43
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.
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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
 
Upvote 0
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
 
Upvote 0
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
 
Upvote 0

Forum statistics

Threads
1,213,497
Messages
6,113,999
Members
448,543
Latest member
MartinLarkin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top