If using xl2000 or later, you can use the worksheet change event for the
sheet cover. Right click on the sheet tab of cover and select view code.
At the top of the resulting module, In the left dropdown select Worksheet
and in the right dropdown select Change (not selectionchange)
I assume if P2 is JI hide sheets, otherwise unhide. If it is the reverse,
then change the <> in the if statement to =
Private Sub Worksheet_Change(ByVal Target As Range)
Dim lFlag as Long
If target.count > 1 then exit sub
if Target.Address = "$P$2" then
if me.Range("P2").value <> "JI" then
lFlag = xlSheetVisible
Else
lFlag = xlSheetHidden
End if
for each sh in Worksheets(Array("data1","data2","data3","data4"))
sh.Visible = lFlag
Next
End if
End Sub
--
Regards,
Tom Ogilvy
Nigel Graham said:
Sorry I need to monitor Cell P2 to check if it says JI in the cell. Cell P2
has a dropdown menu to select various options but only if JI is selected
will all the sheets be pertinent. P2 on the Cover sheet is used to populate
data all over the sheet but data1 - data4 are not pertinent if JI is
selected on the Cover sheet. Users can change the selection P2 whilst using
the workbook to view data from a total of 34 different areas. so they could
view the data with JI populated in P2 then come back and change the
selection later to view different data throughout the rest of the sheet. So
what I need is some VBA to monitor Cover!P2 constantly or at least on view
and on leaving Cover.