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,327
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
32,332
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,295
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,082,360
Messages
5,364,920
Members
400,815
Latest member
Joaquin Phoenix

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top