jjwprotozoa
New Member
- Joined
- Apr 1, 2012
- Messages
- 5
Hi,
I am using excel 2010 and looking for a formula or VBA macro for the following:
<table width="418" border="0" cellpadding="0" cellspacing="0"><colgroup><col style="mso-width-source:userset;mso-width-alt:7753;width:159pt" width="212"> <col style="mso-width-source:userset;mso-width-alt:7533;width:155pt" width="206"> </colgroup><tbody><tr><td valign="top">
</td><td valign="top" align="center">J
</td><td valign="top" align="center">K
</td></tr><tr style="mso-height-source:userset;height:13.5pt" height="18"> <td valign="top">1</td><td style="height:13.5pt;width:159pt;font-size:11.0pt; color:white;font-weight:700;text-decoration:none;text-underline-style:none; text-line-through:none;font-family:Calibri;border-top:.5pt solid #95B3D7; border-right:none;border-bottom:.5pt solid #95B3D7;border-left:none; background:#4F81BD;mso-pattern:#4F81BD none" width="212" height="18">Start Date of Leave
</td> <td style="width:155pt;font-size:11.0pt;color:white;font-weight: 700;text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none; border-bottom:.5pt solid #95B3D7;border-left:none;background:#4F81BD; mso-pattern:#4F81BD none" width="206">End Date of Leave
</td> </tr> <tr style="mso-height-source:userset;height:13.5pt" height="18"> <td valign="top">2
</td><td class="xl65" style="height:13.5pt;font-size:11.0pt; color:black;font-weight:400;text-decoration:none;text-underline-style:none; text-line-through:none;font-family:Calibri;border-top:.5pt solid #95B3D7; border-right:none;border-bottom:.5pt solid #95B3D7;border-left:none; background:#DCE6F1;mso-pattern:#DCE6F1 none" align="right" height="18">3/11/2012</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none; border-bottom:.5pt solid #95B3D7;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none">
</td> </tr> <tr style="mso-height-source:userset;height:13.5pt" height="18"> <td valign="top">3
</td><td class="xl65" style="height:13.5pt;font-size:11.0pt; color:black;font-weight:400;text-decoration:none;text-underline-style:none; text-line-through:none;font-family:Calibri;border-top:.5pt solid #95B3D7; border-right:none;border-bottom:.5pt solid #95B3D7;border-left:none" align="right" height="18">4/2/2012</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight: 400;text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none; border-bottom:.5pt solid #95B3D7;border-left:none" align="right">4/3/2012</td> </tr> <tr style="mso-height-source:userset;height:13.5pt" height="18"> <td valign="top">4
</td><td class="xl65" style="height:13.5pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none; border-bottom:.5pt solid #95B3D7;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="18">
</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none; border-bottom:.5pt solid #95B3D7;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none">
</td> </tr> <tr style="mso-height-source:userset;height:13.5pt" height="18"> <td valign="top">5
</td><td class="xl65" style="height:13.5pt;font-size:11.0pt; color:black;font-weight:400;text-decoration:none;text-underline-style:none; text-line-through:none;font-family:Calibri;border-top:.5pt solid #95B3D7; border-right:none;border-bottom:.5pt solid #95B3D7;border-left:none" align="right" height="18">2/22/2012</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight: 400;text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none; border-bottom:.5pt solid #95B3D7;border-left:none" align="right">2/24/2012</td> </tr> <tr style="mso-height-source:userset;height:13.5pt" height="18"> <td valign="top">6
</td><td class="xl65" style="height:13.5pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none; border-bottom:.5pt solid #95B3D7;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="18">
</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none; border-bottom:.5pt solid #95B3D7;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none">
</td> </tr> </tbody></table>
As you can see above each row has a start date in column J and an end date in column K. Some rows in both columns are blank or the end date column is blank. I want to hide the row if today's date, the date when I run the macro, is between or equal to these two dates. And I need the row to show again one day before the end date.
I have tried using the following, but not getting the results I need.
Sub HideRows()
Dim r as Range, cell as Range
activesheet.Rows.EntireRow.
Please let me know if I need to be more specific.
Thanks in advance.
I am using excel 2010 and looking for a formula or VBA macro for the following:
<table width="418" border="0" cellpadding="0" cellspacing="0"><colgroup><col style="mso-width-source:userset;mso-width-alt:7753;width:159pt" width="212"> <col style="mso-width-source:userset;mso-width-alt:7533;width:155pt" width="206"> </colgroup><tbody><tr><td valign="top">
</td><td valign="top" align="center">J
</td><td valign="top" align="center">K
</td></tr><tr style="mso-height-source:userset;height:13.5pt" height="18"> <td valign="top">1</td><td style="height:13.5pt;width:159pt;font-size:11.0pt; color:white;font-weight:700;text-decoration:none;text-underline-style:none; text-line-through:none;font-family:Calibri;border-top:.5pt solid #95B3D7; border-right:none;border-bottom:.5pt solid #95B3D7;border-left:none; background:#4F81BD;mso-pattern:#4F81BD none" width="212" height="18">Start Date of Leave
</td> <td style="width:155pt;font-size:11.0pt;color:white;font-weight: 700;text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none; border-bottom:.5pt solid #95B3D7;border-left:none;background:#4F81BD; mso-pattern:#4F81BD none" width="206">End Date of Leave
</td> </tr> <tr style="mso-height-source:userset;height:13.5pt" height="18"> <td valign="top">2
</td><td class="xl65" style="height:13.5pt;font-size:11.0pt; color:black;font-weight:400;text-decoration:none;text-underline-style:none; text-line-through:none;font-family:Calibri;border-top:.5pt solid #95B3D7; border-right:none;border-bottom:.5pt solid #95B3D7;border-left:none; background:#DCE6F1;mso-pattern:#DCE6F1 none" align="right" height="18">3/11/2012</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none; border-bottom:.5pt solid #95B3D7;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none">
</td> </tr> <tr style="mso-height-source:userset;height:13.5pt" height="18"> <td valign="top">3
</td><td class="xl65" style="height:13.5pt;font-size:11.0pt; color:black;font-weight:400;text-decoration:none;text-underline-style:none; text-line-through:none;font-family:Calibri;border-top:.5pt solid #95B3D7; border-right:none;border-bottom:.5pt solid #95B3D7;border-left:none" align="right" height="18">4/2/2012</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight: 400;text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none; border-bottom:.5pt solid #95B3D7;border-left:none" align="right">4/3/2012</td> </tr> <tr style="mso-height-source:userset;height:13.5pt" height="18"> <td valign="top">4
</td><td class="xl65" style="height:13.5pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none; border-bottom:.5pt solid #95B3D7;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="18">
</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none; border-bottom:.5pt solid #95B3D7;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none">
</td> </tr> <tr style="mso-height-source:userset;height:13.5pt" height="18"> <td valign="top">5
</td><td class="xl65" style="height:13.5pt;font-size:11.0pt; color:black;font-weight:400;text-decoration:none;text-underline-style:none; text-line-through:none;font-family:Calibri;border-top:.5pt solid #95B3D7; border-right:none;border-bottom:.5pt solid #95B3D7;border-left:none" align="right" height="18">2/22/2012</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight: 400;text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none; border-bottom:.5pt solid #95B3D7;border-left:none" align="right">2/24/2012</td> </tr> <tr style="mso-height-source:userset;height:13.5pt" height="18"> <td valign="top">6
</td><td class="xl65" style="height:13.5pt;font-size:11.0pt;color:black; font-weight:400;text-decoration:none;text-underline-style:none;text-line-through: none;font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none; border-bottom:.5pt solid #95B3D7;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none" height="18">
</td> <td class="xl65" style="font-size:11.0pt;color:black;font-weight:400; text-decoration:none;text-underline-style:none;text-line-through:none; font-family:Calibri;border-top:.5pt solid #95B3D7;border-right:none; border-bottom:.5pt solid #95B3D7;border-left:none;background:#DCE6F1; mso-pattern:#DCE6F1 none">
</td> </tr> </tbody></table>
As you can see above each row has a start date in column J and an end date in column K. Some rows in both columns are blank or the end date column is blank. I want to hide the row if today's date, the date when I run the macro, is between or equal to these two dates. And I need the row to show again one day before the end date.
I have tried using the following, but not getting the results I need.
Sub HideRows()
Dim r as Range, cell as Range
activesheet.Rows.EntireRow.
<wbr>Hidden = False
with Activesheet
set r = .Range(.cells(2,"B"),.cells(<wbr>rows.count,"B").End(xlup))
for each cell in r
if cell.value <= date and date <= cell.offset(0,1).value then
cell.EntireRow.Hidden = True
end if
Next
End With
End Sub
This is for a company transport list. I need the employees on leave to be removed from the list if they are on leave and need them to be added to the list when they return from leave.with Activesheet
set r = .Range(.cells(2,"B"),.cells(<wbr>rows.count,"B").End(xlup))
for each cell in r
if cell.value <= date and date <= cell.offset(0,1).value then
cell.EntireRow.Hidden = True
end if
Next
End With
End Sub
Please let me know if I need to be more specific.
Thanks in advance.