Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-23-2018, 12:41 PM
COgreywolf COgreywolf is offline Cell color based on cell value as compared to another cell va Windows 7 64bit Cell color based on cell value as compared to another cell va Office 2010 64bit
Novice
Cell color based on cell value as compared to another cell va
 
Join Date: Sep 2018
Posts: 4
COgreywolf is on a distinguished road
Default Cell color based on cell value as compared to another cell va


I have a spreadsheet in which I enter daily closing stock prices.

I want to be able to automatically have the cell fill with a color that indicates whether the current day's closing price is one of the following:

1. Higher than the previous day's closing price
2. Lower than the previous day's closing price
3. The same as the previous day's closing price

I have attached part of the spreadsheet I use (and manually fill in the current day cell color based on closing price change from the previous day's closing price). There are days with no data - SAT, SUN, holiday that need to be accounted for so that the correct previous day is referenced.

I appreciate the help.

Thanks.
Attached Files
File Type: xlsx 092318_Excel_Forum_Sample_Spreadsheet.xlsx (10.2 KB, 11 views)
Reply With Quote
  #2  
Old 09-23-2018, 05:24 PM
jeffreybrown jeffreybrown is offline Cell color based on cell value as compared to another cell va Windows Vista Cell color based on cell value as compared to another cell va Office 2007
Expert
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

How about this? Notice on a holiday and/or on a weekend, you need to transfer the values from the day before in order to fulfill the desired conditional format for the next trading day. The font and fill are both grey.

You posted this thread in Excel Programming, but I don't see any reason why you need any VBA as you can achieve this thru CF.
Attached Files
File Type: xlsx 092318_Excel_Forum_Sample_Spreadsheet (1).xlsx (11.5 KB, 8 views)
Reply With Quote
  #3  
Old 09-23-2018, 06:16 PM
COgreywolf COgreywolf is offline Cell color based on cell value as compared to another cell va Windows 7 64bit Cell color based on cell value as compared to another cell va Office 2010 64bit
Novice
Cell color based on cell value as compared to another cell va
 
Join Date: Sep 2018
Posts: 4
COgreywolf is on a distinguished road
Default

I see what you mean by having the FRI value repeated on SAT and SUN so that no "special" handling would be required. I like that.

I am new to the forum so I apologize if I posted it in the incorrect place.

I do not know how to accomplish my desired result using conditional formatting in this regard. That was really the main thrust of what I was asking help on.

Thanks very much for your reply. That got me part of the way there.
Reply With Quote
  #4  
Old 09-24-2018, 12:00 AM
ArviLaanemets ArviLaanemets is offline Cell color based on cell value as compared to another cell va Windows 8 Cell color based on cell value as compared to another cell va Office 2016
Expert
 
Join Date: May 2017
Posts: 873
ArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud of
Default

A possible solution is in attached workbook.

Conditional formatting is defined for column B. I think you can apply the same logic for other columns too. The colors for conditional formatting are selected as near of yours as was possible from default ones in my color palette. Holidays list is a fake one - I added the one you had in your example.

Edit: Weekday numbers in column E are calculated as ISO weekday numbers (European ones). With US weekday numbers the formulas in other columns will be much more complex, and this will affect workbooks performance when data amount increases.
Attached Files
File Type: xlsx 092318_Excel_Forum_Sample_Spreadsheet.xlsx (17.7 KB, 18 views)
Reply With Quote
  #5  
Old 09-24-2018, 11:31 AM
COgreywolf COgreywolf is offline Cell color based on cell value as compared to another cell va Windows 7 64bit Cell color based on cell value as compared to another cell va Office 2010 64bit
Novice
Cell color based on cell value as compared to another cell va
 
Join Date: Sep 2018
Posts: 4
COgreywolf is on a distinguished road
Default

Thanks for your reply.

I somewhat understand what you have done. What I don't get is the mechanics of how the cells in A5:A16 get the appropriate colors assigned. Can you please let me know how this step is done?

Thank you.
Reply With Quote
  #6  
Old 09-24-2018, 11:50 AM
jeffreybrown jeffreybrown is offline Cell color based on cell value as compared to another cell va Windows Vista Cell color based on cell value as compared to another cell va Office 2007
Expert
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

I imagine you are speaking about the last post which seems overkill to me. Why create a column (column E) of formulas to do the conditional formatting when you can apply the condition directly to the cells.

Maybe looking at some tutorials will help...

https://exceljet.net/conditional-for...-with-formulas
https://www.contextures.com/xlCondFormat03.html
https://www.ablebits.com/office-addi...matting-dates/

These are just a few tutorials pasted around the internet. We could retype these steps, but since they are already typed out and not exactly sure what you are understanding, there should help.
Reply With Quote
  #7  
Old 09-24-2018, 11:17 PM
ArviLaanemets ArviLaanemets is offline Cell color based on cell value as compared to another cell va Windows 8 Cell color based on cell value as compared to another cell va Office 2016
Expert
 
Join Date: May 2017
Posts: 873
ArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud of
Default

Quote:
Originally Posted by jeffreybrown View Post
I imagine you are speaking about the last post which seems overkill to me. Why create a column (column E) of formulas to do the conditional formatting when you can apply the condition directly to the cells.

I defined tHolidays as a Table (to make it dynamic). Conditional formatting doesn't recognize Tables, and it doesn't work with named ranges either.

The number of calculated columns may be reduced, but I kept every step to make for OP easier to understand the logic. And the number of calculated columns is really moot, OP can hide them, and having several columns with simple formulas may be advantageous compared with one column with super-complex formula.

Instead of OP, I'd define the table on data sheet as Table too. Currently I left it as it was originally, but this means whenever a new rows of data are added (or rows are removed), all range references must be edited in all formulas - which means a lot of unneeded work. (And all conditional formatting rules must be edited too, when OP wants to do all calculations there. And those calculations will get quite complex too with references to several ranges on different sheets for every condition.) With Table defined on data entry sheet and all formulas replaced with Table formulas, the whole workbook will be dynamic. But this means, that there mus be a column in data entry Table, which determines conditional formatting condition for every row.
Reply With Quote
  #8  
Old 09-24-2018, 11:28 PM
ArviLaanemets ArviLaanemets is offline Cell color based on cell value as compared to another cell va Windows 8 Cell color based on cell value as compared to another cell va Office 2016
Expert
 
Join Date: May 2017
Posts: 873
ArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud ofArviLaanemets has much to be proud of
Default

Quote:
Originally Posted by COgreywolf View Post
What I don't get is the mechanics of how the cells in A5:A16 get the appropriate colors assigned.
Search for Conditional Formatting in help!

Activate a cell in column B with prices, and select from Menu Home>Conditional Formatting>Manage Rules. 5 rules (a rule for every color) are defined there.

When you want to apply conditional formatting to columns C and D too, you need additional 2 calculated columns with previous workday values for those columns, and additional 5 conditional formatting rules for every of those columns.
Reply With Quote
  #9  
Old 09-25-2018, 04:09 AM
jeffreybrown jeffreybrown is offline Cell color based on cell value as compared to another cell va Windows Vista Cell color based on cell value as compared to another cell va Office 2007
Expert
 
Join Date: Apr 2016
Posts: 673
jeffreybrown has a spectacular aura aboutjeffreybrown has a spectacular aura about
Default

Quote:
Originally Posted by ArviLaanemets View Post
Conditional formatting doesn't recognize Tables, and it doesn't work with named ranges either.
You might want to check the part about CF not working with named ranges.

I defined a block of 3 numbers and assigned the named range MyNumbers to it. In those cells I typed in 1, 1, and 1.

As an example, I used in CF >> =SUM(MyNumbers)=3

Works okay for me.
Reply With Quote
  #10  
Old 09-25-2018, 12:28 PM
COgreywolf COgreywolf is offline Cell color based on cell value as compared to another cell va Windows 7 64bit Cell color based on cell value as compared to another cell va Office 2010 64bit
Novice
Cell color based on cell value as compared to another cell va
 
Join Date: Sep 2018
Posts: 4
COgreywolf is on a distinguished road
Default

Thank you all. The videos online suggested were a great help. I finally got it!

This thread can now be marked closed.

Thanks again.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell color based on cell value as compared to another cell va looking to change cell color by typing number into the cell ibs Word Tables 1 11-22-2016 06:31 PM
Cell color based on cell value as compared to another cell va Entering a number in a cell causes it to fill with the color of a nearby cell Bill Martz Excel 1 04-23-2015 07:57 PM
Cell color based on cell value as compared to another cell va Cell Background Color: Base it on Content of Cell? tatihulot Excel 4 08-14-2013 03:24 PM
How can I fill cell color starting from Cell D5 using Conditional formatting instead Learner7 Excel 0 07-08-2010 05:50 AM
How can I make a cell color RED under the Today's date cell? Learner7 Excel 2 07-08-2010 12:52 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:04 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft