Change row color based on a date in one cell

capncaveman

New Member
Joined
Jan 6, 2010
Messages
7
What I would like to do is have a spreadsheet with our online orders and keep track of when the orders go beyond a certain date.

For instance. I have all the order information on one row. One of these cells will be an order date. I would like to have that whole row green within one week of the order date and then turn yellow from 1 week to 2 weeks and turn red beyond 2 weeks from the order date. The order dates will always be different so the formula will have to go off of the order date...not the current date.

I would also like to have a cell with a check box or a cell where I can enter "Shipped" and it will then turn the row back to white.

Is this possible? I am using Excel 2007

Any help would be appreciated!!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Hello,

Welcome to the board!!

Shortcut keys --> Alt+F11 to open VBEditor
Keystrokes --> Alt - I - M to insert Standard Module
Paste in the below code
Within the VBeditor press F5 to run
Or
Close the VBEditor, Shortcut Keys ALT+F8 to run
This code may be called by other means including assingning to a button


<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> ShipDate()<br><br><SPAN style="color:#00007F">Dim</SPAN> cell            <SPAN style="color:#00007F">As</SPAN> Range, _<br>    fC              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    lC              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    dC              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    dR              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <br>fC = "A" <SPAN style="color:#007F00">''' Change to first Column with data, colors will start here</SPAN><br>lC = "F" <SPAN style="color:#007F00">''' Change to last Column with data, colors will end here</SPAN><br>dC = "C" <SPAN style="color:#007F00">''' Change to Column with date</SPAN><br>dR = 2   <SPAN style="color:#007F00">''' Change to first row of date in above Column</SPAN><br><br><br>    <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> cell <SPAN style="color:#00007F">In</SPAN> Range(dC & dR & ":" & dC & Range(dC & Rows.Count).End(xlUp).Row)<br>        <SPAN style="color:#00007F">If</SPAN> UCase(cell.Offset(0, 3).Value) <> "SHIPPED" <SPAN style="color:#00007F">Then</SPAN><br>            <SPAN style="color:#00007F">If</SPAN> cell.Value < <SPAN style="color:#00007F">Date</SPAN> - 14 <SPAN style="color:#00007F">Then</SPAN><br>                <SPAN style="color:#007F00">'cell.Offset(0, 1).Value = "Here 14"</SPAN><br>                Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(220, 30, 0)<br>            <SPAN style="color:#00007F">ElseIf</SPAN> cell.Value < <SPAN style="color:#00007F">Date</SPAN> - 7 <SPAN style="color:#00007F">Then</SPAN><br>                <SPAN style="color:#007F00">'cell.Offset(0, 1).Value = "Here 7"</SPAN><br>                Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(220, 220, 0)<br>            <SPAN style="color:#00007F">Else</SPAN><br>                Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(0, 220, 30)<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>        <SPAN style="color:#00007F">Else</SPAN><br>        Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Pattern = xlNone<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>    <SPAN style="color:#00007F">Next</SPAN> cell<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Change the commented places to your values.

Does that help?

-Jeff
 
Upvote 0
I forgot to mention this uses a column for marking as shipped.

Here is an update to specify the column for this.

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> ShipDate()<br><br><SPAN style="color:#00007F">Dim</SPAN> cell            <SPAN style="color:#00007F">As</SPAN> Range, _<br>    fC              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    lC              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    dC              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    dR              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, _<br>    ShC             <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <br>    <br>fC = "A"    <SPAN style="color:#007F00">''' Change to first Column with data, colors will start here</SPAN><br>lC = "F"    <SPAN style="color:#007F00">''' Change to last Column with data, colors will end here</SPAN><br>dC = "C"    <SPAN style="color:#007F00">''' Change to Column with date</SPAN><br>dR = 2      <SPAN style="color:#007F00">''' Change to first row of date in above Column</SPAN><br>ShC = 3     <SPAN style="color:#007F00">'''Enter Cell offset for the shipped column. _<br>                        (Start at date Column, count columns until Shipped column) _<br>                        (Positive to the right, Negative to the left)</SPAN><br>                        <br>                        <br>    <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> cell <SPAN style="color:#00007F">In</SPAN> Range(dC & dR & ":" & dC & Range(dC & Rows.Count).End(xlUp).Row)<br>        <SPAN style="color:#00007F">If</SPAN> UCase(cell.Offset(0, ShC).Value) <> "SHIPPED" <SPAN style="color:#00007F">Then</SPAN><br>            <SPAN style="color:#00007F">If</SPAN> cell.Value < <SPAN style="color:#00007F">Date</SPAN> - 14 <SPAN style="color:#00007F">Then</SPAN><br>                <SPAN style="color:#007F00">'cell.Offset(0, 1).Value = "Here 14"</SPAN><br>                Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(220, 30, 0)<br>            <SPAN style="color:#00007F">ElseIf</SPAN> cell.Value < <SPAN style="color:#00007F">Date</SPAN> - 7 <SPAN style="color:#00007F">Then</SPAN><br>                <SPAN style="color:#007F00">'cell.Offset(0, 1).Value = "Here 7"</SPAN><br>                Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(220, 220, 0)<br>            <SPAN style="color:#00007F">Else</SPAN><br>                Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(0, 220, 30)<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>        <SPAN style="color:#00007F">Else</SPAN><br>        Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Pattern = xlNone<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>    <SPAN style="color:#00007F">Next</SPAN> cell<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>



<b>Excel 2007</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">order date</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: right;background-color: #00DC1E;;"></td><td style="text-align: right;background-color: #00DC1E;;"></td><td style="text-align: right;background-color: #00DC1E;;">7/13/2011</td><td style="text-align: right;background-color: #00DC1E;;"></td><td style="text-align: right;background-color: #00DC1E;;"></td><td style="text-align: right;background-color: #00DC1E;;"></td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: right;background-color: #00DC1E;;"></td><td style="text-align: right;background-color: #00DC1E;;"></td><td style="text-align: right;background-color: #00DC1E;;">7/10/2011</td><td style="text-align: right;background-color: #00DC1E;;"></td><td style="text-align: right;background-color: #00DC1E;;"></td><td style="text-align: right;background-color: #00DC1E;;"></td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="text-align: right;background-color: #DCDC00;;"></td><td style="text-align: right;background-color: #DCDC00;;"></td><td style="text-align: right;background-color: #DCDC00;;">7/5/2011</td><td style="background-color: #DCDC00;;">Here 7</td><td style="text-align: right;background-color: #DCDC00;;"></td><td style="text-align: right;background-color: #DCDC00;;"></td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;">7/1/2011</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">Shipped</td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style="text-align: right;background-color: #DC1E00;;"></td><td style="text-align: right;background-color: #DC1E00;;"></td><td style="text-align: right;background-color: #DC1E00;;">6/25/2011</td><td style="background-color: #DC1E00;;">Here 14</td><td style="text-align: right;background-color: #DC1E00;;"></td><td style="text-align: right;background-color: #DC1E00;;"></td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;">6/15/2011</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">Shipped</td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style="text-align: right;background-color: #DC1E00;;"></td><td style="text-align: right;background-color: #DC1E00;;"></td><td style="text-align: right;background-color: #DC1E00;;">6/6/2011</td><td style="background-color: #DC1E00;;">Here 14</td><td style="text-align: right;background-color: #DC1E00;;"></td><td style="text-align: right;background-color: #DC1E00;;"></td></tr><tr ><td style="color: #161120;text-align: center;">9</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;">6/29/2011</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style=";">shipped</td></tr><tr ><td style="color: #161120;text-align: center;">10</td><td style="text-align: right;background-color: #DC1E00;;"></td><td style="text-align: right;background-color: #DC1E00;;"></td><td style="text-align: right;background-color: #DC1E00;;">6/28/2011</td><td style="background-color: #DC1E00;;">Here 14</td><td style="text-align: right;background-color: #DC1E00;;"></td><td style="text-align: right;background-color: #DC1E00;;"></td></tr><tr ><td style="color: #161120;text-align: center;">11</td><td style="text-align: right;background-color: #DCDC00;;"></td><td style="text-align: right;background-color: #DCDC00;;"></td><td style="text-align: right;background-color: #DCDC00;;">6/30/2011</td><td style="background-color: #DCDC00;;">Here 7</td><td style="text-align: right;background-color: #DCDC00;;"></td><td style="text-align: right;background-color: #DCDC00;;"></td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet1</p><br /><br />
 
Upvote 0
Hey! Thanks for the quick response!!!

I am very green at Excel but I managed to make a couple of changes but I am having trouble fine tuning this code. Since I dont know VB that poses kind of a problem lol.

There will be times where I will have to skip rows and not enter a date to accommodate multiple back ordered items per order. When this happens the code seems to want those lines red with no data in the date cell. I have no clue how to fix that.

Also I changed the first row with a date to 5 and it made 3 lines red and one green above row 5. Row 1 and 2 were white and rows 3 and 4 were orange. Again I have no idea why. Thank you again for your help.

The file I am working with can be found below
http://www.toolhouseinc.com/media/test.xlsm
 
Upvote 0
Hello,

Clear any colors you may have in the first 5 rows.

Replace the old code with the below and then test to see if it works as you would like.

I did make the 'undated' row a different color.


Here is the code:

<font face=Courier New><br><SPAN style="color:#00007F">Sub</SPAN> ShipDate()<br><br><SPAN style="color:#00007F">Dim</SPAN> cell            <SPAN style="color:#00007F">As</SPAN> Range, _<br>    fC              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    lC              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    dC              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    dR              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, _<br>    ShC             <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <br>    <br>fC = "A"    <SPAN style="color:#007F00">''' Change to first Column with data, colors will start here</SPAN><br>lC = "L"    <SPAN style="color:#007F00">''' Change to last Column with data, colors will end here</SPAN><br>dC = "B"    <SPAN style="color:#007F00">''' Change to Column with date</SPAN><br>dR = 5      <SPAN style="color:#007F00">''' Change to first row of date in above Column</SPAN><br>ShC = 10    <SPAN style="color:#007F00">'''Enter Cell offset for the shipped column. _<br>                        (Start at date Column, count columns until Shipped column) _<br>                        (Positive to the right, Negative to the left)</SPAN><br>                        <br>                        <br>    <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> cell <SPAN style="color:#00007F">In</SPAN> Range(dC & dR & ":" & dC & Range(dC & Rows.Count).End(xlUp).Row)<br>        <SPAN style="color:#007F00">'MsgBox cell.Value = ""</SPAN><br>        <SPAN style="color:#00007F">If</SPAN> UCase(cell.Offset(0, ShC).Value) <> "SHIPPED" And cell.Value <> "" <SPAN style="color:#00007F">Then</SPAN><br>            <SPAN style="color:#00007F">If</SPAN> cell.Value < <SPAN style="color:#00007F">Date</SPAN> - 14 <SPAN style="color:#00007F">Then</SPAN><br>                <SPAN style="color:#007F00">'cell.Offset(0, 1).Value = "Here 14"</SPAN><br>                Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(220, 30, 0)<br>            <SPAN style="color:#00007F">ElseIf</SPAN> cell.Value < <SPAN style="color:#00007F">Date</SPAN> - 7 <SPAN style="color:#00007F">Then</SPAN><br>                <SPAN style="color:#007F00">'cell.Offset(0, 1).Value = "Here 7"</SPAN><br>                Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(230, 230, 0)<br>            <SPAN style="color:#00007F">Else</SPAN><br>                Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(0, 220, 30)<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>        <SPAN style="color:#00007F">Else</SPAN><br>            <SPAN style="color:#00007F">If</SPAN> cell.Value = "" <SPAN style="color:#00007F">Then</SPAN><br>                Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(0, 240, 180)<br>            <SPAN style="color:#00007F">Else</SPAN><br>                Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Pattern = xlNone<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>    <SPAN style="color:#00007F">Next</SPAN> cell<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN></FONT>

Let me know how this does for you.

-Jeff
 
Upvote 0
It works perfect! I dont know how you do this stuff! Thanks a million!!!

Say for instance if you have 5 rows with dates and they are colored their respective colors. When you delete the data from all 5 of them...which will happen in my case, the data is deleted but only the top row turns back to white and the remaining rows stay the color that they were changed to based on the date. Do I have to just highlight those and say no fill or is it even possible to add to the VB code?
 
Upvote 0
Hello,

Every bit of VBA knowledge I have has came from mrexcel site.

It takes some time, but helping others has proven to be the best way to really learn.

I have came up with a way to delete all of your data in the form and leave it blank down to the headers. What I have done is to use two buttons along the top and assigned these two macros to them.

Here is what I am using:

<font face=Courier New><SPAN style="color:#00007F">Sub</SPAN> ShipDate()<br><br><SPAN style="color:#00007F">Dim</SPAN> cell            <SPAN style="color:#00007F">As</SPAN> Range, _<br>    fC              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    lC              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    dC              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    dR              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, _<br>    ShC             <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <br>    <br>fC = "A"    <SPAN style="color:#007F00">''' Change to first Column with data, colors will start here</SPAN><br>lC = "L"    <SPAN style="color:#007F00">''' Change to last Column with data, colors will end here</SPAN><br>dC = "B"    <SPAN style="color:#007F00">''' Change to Column with date</SPAN><br>dR = 5      <SPAN style="color:#007F00">''' Change to first row of date in above Column</SPAN><br>ShC = 10    <SPAN style="color:#007F00">'''Enter Cell offset for the shipped column. _<br>                        (Start at date Column, count columns until Shipped column) _<br>                        (Positive to the right, Negative to the left)</SPAN><br><br>    <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> cell <SPAN style="color:#00007F">In</SPAN> Range(dC & dR & ":" & dC & Range(dC & Rows.Count).End(xlUp).Row)<br>        <SPAN style="color:#00007F">If</SPAN> UCase(cell.Offset(0, ShC).Value) <> "SHIPPED" And cell.Value <> "" <SPAN style="color:#00007F">Then</SPAN><br>            <br>            <SPAN style="color:#00007F">If</SPAN> cell.Value < <SPAN style="color:#00007F">Date</SPAN> - 14 <SPAN style="color:#00007F">Then</SPAN><br>                Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(220, 30, 0)<br>            <SPAN style="color:#00007F">ElseIf</SPAN> cell.Value < <SPAN style="color:#00007F">Date</SPAN> - 7 <SPAN style="color:#00007F">Then</SPAN><br>                Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(230, 230, 0)<br>            <SPAN style="color:#00007F">Else</SPAN><br>                Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(0, 220, 30)<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>        <SPAN style="color:#00007F">Else</SPAN><br>            <SPAN style="color:#00007F">If</SPAN> cell.Value = "" <SPAN style="color:#00007F">Then</SPAN><br>                Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(0, 240, 180)<br>            <SPAN style="color:#00007F">Else</SPAN><br>                Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Pattern = xlNone<br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>    <SPAN style="color:#00007F">Next</SPAN> cell<br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br><br><br><br><SPAN style="color:#00007F">Sub</SPAN> ClearData()<br><br><SPAN style="color:#00007F">Dim</SPAN> cell    <SPAN style="color:#00007F">As</SPAN> Range, _<br>    dC      <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    dR      <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, _<br>    fC      <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    lC      <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    dCR     <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>     <br>fC = "A"    <SPAN style="color:#007F00">''' Change to first Column with data, colors will start here</SPAN><br>lC = "L"    <SPAN style="color:#007F00">''' Change to last Column with data, colors will end here</SPAN><br>dC = "B"    <SPAN style="color:#007F00">''' Change to Column with date</SPAN><br>dR = 5      <SPAN style="color:#007F00">''' Change to first row of date in above Column</SPAN><br>    <br>    <SPAN style="color:#00007F">If</SPAN> MsgBox("This action will clear all data entries within form." & vbNewLine & _<br>            "Continue?", vbYesNo, "Delete all Data???") = vbYes <SPAN style="color:#00007F">Then</SPAN><br>        <SPAN style="color:#00007F">If</SPAN> Range(dC & Rows.Count).End(xlUp).Row < 5 <SPAN style="color:#00007F">Then</SPAN><br>            dCR = 5<br>        <SPAN style="color:#00007F">Else</SPAN><br>            dCR = Range(dC & Rows.Count).End(xlUp).Row<br>        <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>            <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> cell <SPAN style="color:#00007F">In</SPAN> Range(dC & dR & ":" & dC & dCR)<br>                 <SPAN style="color:#007F00">'Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Pattern = xlNone</SPAN><br>                 Range(fC & cell.Row & ":" & lC & cell.Row).Clear<br>            <SPAN style="color:#00007F">Next</SPAN> cell<br>    <SPAN style="color:#00007F">Else</SPAN><br>        <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>End <SPAN style="color:#00007F">Sub</SPAN></FONT>


Also I have tried to take the automation a step further for you in hopes of receiving a Fein MM top plus. :rolleyes: :rofl:


Right click the sheet tab
Select veiw code

Paste in the below code
<font face=Courier New><SPAN style="color:#00007F">Private</SPAN> <SPAN style="color:#00007F">Sub</SPAN> Worksheet_Change(<SPAN style="color:#00007F">ByVal</SPAN> Target <SPAN style="color:#00007F">As</SPAN> Range)<br><br><SPAN style="color:#00007F">Dim</SPAN> changed         <SPAN style="color:#00007F">As</SPAN> Range, _<br>    cell            <SPAN style="color:#00007F">As</SPAN> Range, _<br>    fC              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    lC              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    dC              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">String</SPAN>, _<br>    dR              <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN>, _<br>    ShC             <SPAN style="color:#00007F">As</SPAN> <SPAN style="color:#00007F">Long</SPAN><br>    <br>fC = "A"    <SPAN style="color:#007F00">''' Change to first Column with data, colors will start here</SPAN><br>lC = "L"    <SPAN style="color:#007F00">''' Change to last Column with data, colors will end here</SPAN><br>dC = "B"    <SPAN style="color:#007F00">''' Change to Column with date</SPAN><br>dR = 5      <SPAN style="color:#007F00">''' Change to first row of date in above Column</SPAN><br>ShC = 10    <SPAN style="color:#007F00">'''Enter Cell offset for the shipped column. _<br>                        (Start at date Column, count columns until Shipped column) _<br>                        (Positive to the right, Negative to the left)</SPAN><br>                        <br><SPAN style="color:#00007F">Set</SPAN> changed = Intersect(Target, Range("B5:B" & Range("B" & Rows.Count).End(xlUp).Row))<br><br><SPAN style="color:#00007F">If</SPAN> Target.Cells.Count > 1 <SPAN style="color:#00007F">Then</SPAN> <SPAN style="color:#00007F">Exit</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br><br>    <SPAN style="color:#00007F">If</SPAN> <SPAN style="color:#00007F">Not</SPAN> changed <SPAN style="color:#00007F">Is</SPAN> <SPAN style="color:#00007F">Nothing</SPAN> <SPAN style="color:#00007F">Then</SPAN><br>        <SPAN style="color:#00007F">For</SPAN> <SPAN style="color:#00007F">Each</SPAN> cell <SPAN style="color:#00007F">In</SPAN> Range(dC & dR & ":" & dC & Range(dC & Rows.Count).End(xlUp).Row)<br>            <SPAN style="color:#00007F">If</SPAN> UCase(cell.Offset(0, ShC).Value) <> "SHIPPED" And cell.Value <> "" <SPAN style="color:#00007F">Then</SPAN><br>                <SPAN style="color:#00007F">If</SPAN> cell.Value < <SPAN style="color:#00007F">Date</SPAN> - 14 <SPAN style="color:#00007F">Then</SPAN><br>                    Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(220, 30, 0)<br>                <SPAN style="color:#00007F">ElseIf</SPAN> cell.Value < <SPAN style="color:#00007F">Date</SPAN> - 7 <SPAN style="color:#00007F">Then</SPAN><br>                    Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(230, 230, 0)<br>                <SPAN style="color:#00007F">Else</SPAN><br>                    Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(0, 220, 30)<br>                <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>            <SPAN style="color:#00007F">Else</SPAN><br>                <SPAN style="color:#00007F">If</SPAN> cell.Value = "" <SPAN style="color:#00007F">Then</SPAN><br>                    Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Color = RGB(0, 240, 180)<br>                <SPAN style="color:#00007F">Else</SPAN><br>                    Range(fC & cell.Row & ":" & lC & cell.Row).Interior.Pattern = xlNone<br>                <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>            <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br>        <SPAN style="color:#00007F">Next</SPAN> cell<br>    <SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">If</SPAN><br><SPAN style="color:#00007F">End</SPAN> <SPAN style="color:#00007F">Sub</SPAN><br><br><br></FONT>

It is basically the same as the other, only this should be triggered by any entry in the date column.

-Jeff
 
Upvote 0
All lovely bits of code, but can I ask a question .... why not use Conditional Formatting for this?

Excel Workbook
ABCDEF
1order date
213/07/2011
310/07/2011
405/07/2011
501/07/2011Shipped
625/06/2011
715/06/2011Shipped
806/06/2011
929/06/2011shipped
1028/06/2011
1130/06/2011
Sheet1


... formatted using:
selection of A2:F11
... condition 1
formula:=$F2="Shipped"
format:no format
stop if true: ticked

condition 2
formula:=$C2<(TODAY()-14)
format:fill red
stop if true: ticked

condition 3
formula:=$C2<(TODAY()-7)
format: fill yellow
stop if true: ticked

condition 4
formula:=$C2>=(TODAY()-7)
format: fill green
stop if true: ticked
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,827
Members
452,946
Latest member
JoseDavid

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