Posted to microsoft.public.excel.programming
|
|
Hide, unhide macro
type 29/2/2009 into a cell, say A1. in another cell type =MONTH(A1) and
you'll get #Value
Certainly DateSerial(year,month,0) will always return the last day of the
preceding month
"Archimedes' Lever" wrote in message
...
On Sat, 13 Jun 2009 17:11:14 +0100, "Patrick Molloy"
wrote:
issue is that 29th Feb of a non-leap year year doesn't resolve to a date,
Yes it does. In EVERY case, it will resolve to march 1st, so the test
that we all use, which DOES work, is to test for the month number that a
given excel internal date number resolves to, so if you declare a date,
and test it for the month number, a Feb 29 date of ANY leap year results
in a 3 for the month number.
As in:
=IF(MONTH(A29+1)=2,A29+1,NA())
Were "A29" refers to a 28th row (and date reference) in a data table.
It could easily ask about a specific date reference as well, instead of
a cell's contents.
and could raise an exception if not handled correctly
you could try the 0th day of March ...
eg
DAY(DateSerial(2008, 3, 0))
will be 28 or 29 for leap year
We have the test solved. What I need is the response action segment.
"TheQuickBrownFox" wrote in message
. ..
Hey guys,
I have a test in a cell that examines if 2-29-xxxx (where xxxx is year
of choice) resolves to a month number of 3 or 2 which is a way of
determining a leap year. After such a test, I want to hide or unhide a
row in two different worksheets in a workbook. So the script would test
the value of the cell where I resolve a logical for the leap year (or
that can be done in the macro as well, no?), and then based on that
test,
hide or unhide one row in the February worksheet, and the annual
worksheet. This has the effect of auto-magically adjusting the charts
that refer to these two sheets, which is a lot easier than trying to
dynamically adjust both the charts and the sheets. So, the hiding and
unhiding IS the right way to go, unless you have some kind of "Ignore
Row" function for the data or the chart. :-)
I previously assigned a hide and unhide button and tied it to a macro
segment, in those two sheets. That works, but it still requires the user
to perform the hide/unhide operation while knowing or after reading the
conditional leap year test results cell contents.
I guess I need an "IF "such and such" is true, THEN hide row such and
such in sheet such and such, and hide row such in such in other sheet
such and such, ELSE UNhide yada yada yada.
This is the sheet, minus the macros:
http://office.microsoft.com/search/r... 101436151033
|