Formatting Cell Based on content using Conditional Formatting

itsrich

New Member
Joined
Apr 13, 2009
Messages
49
Office Version
  1. 2019
Platform
  1. Windows
I want the cell containing the following formula to change the fill color when the formula results in a date. =IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D3,'Where is production'!$D:$D,0),5)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D3,'Where is production'!$D:$D,0),5))

The result of the formula is text or number

Currently, I am attempting to use conditional formatting to format the cell, but the text and numbers are formatted the same. I can figure out how to determine the difference between a number and text.

TY for your help
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
isnumber()
istext()

if its a date you want to fill the cell

A date is just a number - (number of days since 1900, but can also be text and so not a real date
maybe a sample here

check the source if its a real date by changing the format to general and see if you get a number
 
Upvote 0
The Orange row is the formatted row. See below for a picture of the conditional formatting settings.
Once I figure out how to do this for the column I am working on, I will use it on the other columns.

When I clear all formatting I get Excel's number system for the date and text for this column.

I think there is knowledge I need to master about how the "state" of cells changes. I have not found that nugget of info yet. I think once I have a better handle on this, my spreadsheets will move to the next level. I am so thankful for Mr. Excel. This is the only place I have found to help me learn!

Cell Formulas
RangeFormula
I23:I47I23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),1)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),1))
J23:J47J23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),2)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),2))
K23:K47K23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),3)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),3))
L23:L47L23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),4)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),4))
M23:M47M23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),5)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),5))
N23:N47N23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),6)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),6))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
M3:M47Expression=ISNUMBER($M$4:$M$47)textNO


2023.02.13 MR Excel.PNG
 
Upvote 0
because of reference to other sheets, I cannot copy in

if you elect a range in column N

now change the format to a number

if nothing changes , then all those values are text

something like

Book1
E
144896
244897
344898
444899
544900
644901
744902
844903
944904
1012-jan
1113-dec
Sheet1
 
Upvote 0
This is the same range with all formatting stripped. The Excel 5-digit date & text ("x" and "WIP"), are sourced from other sheets.

Cell Formulas
RangeFormula
I23:I47I23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),1)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),1))
J23:J47J23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),2)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),2))
K23:K47K23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),3)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),3))
L23:L47L23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),4)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),4))
M23:M47M23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),5)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),5))
N23:N47N23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),6)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),6))
 
Upvote 0
ok, so they are dates

how about this using isnumber() and istext()

The column B is just to show the dates formatted as a number

again your example does not copy -

Book2
AB
1
21-Feb44958
32-Feb44959
43-Feb44960
54-Feb44961
65-Feb44962
76-Feb44963
87-Feb44964
9xx
109-Feb44966
11wipwip
1211-Feb44968
13ss
1413-Feb44970
1514-Feb44971
1615-Feb44972
Sheet2
Cell Formulas
RangeFormula
B2:B16B2=A2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A16Expression=ISTEXT(A2)textNO
A2:A16Expression=AND(ISNUMBER(A2),A2<>"")textNO


Otherwise

need to show what you want conditional formatted - or i'm not understanding - SORRY
 
Upvote 0
Hmmm. The only difference is you reference one cell where I have a range. I am focusing on column M.

Cell Formulas
RangeFormula
I23:I47I23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),1)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),1))
J23:J47J23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),2)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),2))
K23:K47K23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),3)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),3))
L23:L47L23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),4)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),4))
M23:M47M23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),5)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),5))
N23:N47N23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),6)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),6))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
M23Expression=ISTEXT($M$23:$M$47)textNO
M23Expression=AND(ISNUMBER($M$23:$M$47),$M$23:$M$47<>"")textNO
 
Upvote 0
you are referencing a range not a single cell ???
so select M23:M47
and not just M23

then use
=ISTEXT($M23)
NOTE the $ is only on the column NOT the row
and then
=AND(ISNUMBER($M23),$M23<>"")

thats the difference

look at my conditional formatting box compared to you on the XL2BB

Mine
CellConditionCell FormatStop If True
Cells with Conditional Formatting
A2:A16Expression=ISTEXT(A2)textNO
A2:A16Expression=AND(ISNUMBER(A2),A2<>"")textNO


yours
CellConditionCell FormatStop If True
Cells with Conditional Formatting
M23Expression=ISTEXT($M$23:$M$47)textNO
M23Expression=AND(ISNUMBER($M$23:$M$47),$M$23:$M$47<>"")textNO
 
Upvote 0
I realized we did not need as much of the spreadsheet to have this discussion.

My Excel Just shut down and went to the recovery of all my spreadsheets. I am going to have to put this down until tomorrow or the next day. I have to figure out what was lost. I have lost everything we have talked about here.

This is where I left off. Not sure why the conditional formatting is formatting numbers as text.

2023.02.13 FAB Tracking & Reporting Sheet.xlsx
M
2344944
2444944
2544900
2644911
27X
2844944
2944911
3044911
3144944
3244944
3344956
3444956
3544950
3644945
3744944
3844945
3944945
40WIP
41WIP
4244944
4344944
44WIP
45WIP
4644951
4744951
The Time Line CURRENT
Cell Formulas
RangeFormula
M23:M47M23=IF(ISBLANK(INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),5)),"",INDEX('Where is production'!$G:$N,MATCH('The Time Line CURRENT'!D23,'Where is production'!$D:$D,0),5))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
M:MExpression=ISTEXT($M23:$M47)textNO
M:MExpression=AND(ISNUMBER($M23:$M47),$M23:$M47<>"")textNO
 
Upvote 0
now your selection is out of sync with the formula
you are selecring all of the rows in column M
so it starts at row 1 and then colours
But the test is M23 - and you have selected an array

so still not the correct entry for conditional formatting - the formula does not have an array

so when you select say M1:M20 - and have a formula like =M1="fred"
conditional formatting will start looking at M1, as thats whats selected and test to see if that sell M1 as thats in the formula contains fred
it then moves on to the next cell
M2
and the moves to the next cell
M3
and stops at M20 - as thats what you have selected

so now the formula should be

=ISTEXT($M1)
=AND(ISNUMBER($M1),$M1<>"")

as i have done in my example
i selected A2 to A16
and then the formula refers to A2


for example
Book2
D
1
2
3
4
5fred
6
7
8
9
10
11
12
13
14
15
16
17
Sheet2
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D4:D15Expression=D1="fred"textNO


I selected
$D$4:$D$15
and then the formula

is D1=Fred

Now thats out by 3 rows
the selection starts at row4 - but the formula test to see if fred is in D1
then moves to D2 - selection moves to D5
then moves to D3 - selection moves to D6
then moves to D4 - selection moves to D7
then moves to D5 - selection moves to D8
so D5 does have fred - BUT the selection is now at D8 and so highlights the wrong cell
because the rows selected are out of sync with the formula

as we selected D4;D15
the formula starts at D4
=D4 = fred

hope that makes sense
 
Last edited:
Upvote 1
Solution

Forum statistics

Threads
1,214,827
Messages
6,121,803
Members
449,048
Latest member
greyangel23

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