View Single Post
  #13   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy Patrick Molloy is offline
external usenet poster
 
Posts: 1,049
Default Hide, unhide macro

add this code to the sheet "User Info" code page

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = Range("Bloodyear").Address Then
checkLeapYear Target.Value
End If
End Sub

Private Sub checkLeapYear(yr As Long)
Dim bLeapYear As Boolean
If yr Mod 4 = 0 Then
If yr Mod 100 = 0 Then
If yr / 100 Mod 4 = 0 Then
bLeapYear = True
End If
Else
bLeapYear = True
End If
End If
Worksheets("February Tests").Rows(42).Hidden = Not bLeapYear
End Sub


"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