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.
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