Macro to show/hide rows based on a range of dates
I have a spreadsheet in which users enter data each day with each row being a
record for a single day. Column B holds the dates beginning at B2 and going
down to whatever is the last date. At least one year of data will be in the
spreadsheet but it is very likely that several years' worth of data could be
collected in the spreadsheet. I would like to have just the current day and
and a limited range of preceding days displayed by default when the
spreadsheet is opened. This could be just the current day and a fixed number
of preceding days (such as 5 or 10). Ideally, users would just see the
current day, the preceding days of the current work week, and all the days of
the previous work week. A work week is Mon.-Fri. No data is collected for
non-working days and no non-working dates are on the sheet. The spreadsheet
has been set up with dates going to the end of the current year (and this may
be extended to the end of the next year or even beyond). However, users
wouldn't need to see future days because these are irrelevant until data is
available to fill in for those dates. I would like to give users the option
to toggle a checkbox or radio button to show all dates from the current day
to the earliest date in the spreadsheet or just those dates shown by default.
I have found several examples of code to hide/show rows or columns based on
various criteria, including a date, but I am having trouble putting it all
together, particularly with a toggle for a date range (either a simple fixed
number date range or the date range I described as ideal). I would appreciate
any suggestions or help.
|