Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Hide/Unhide worksheets upon entries in a range of the main worksheet

I have a workbook with 6 worksheets of the same format (name it target
1-6). In my main worksheet (name it assessment) I have an overview of
related values. In cells A5:A10 of the latter, I give a catch-word for
each target, which then will be displayed in the respecitive target
worksheet. In cells F5:F10 I give the weight of each target (e.g. 10,
20, or blank, if no weight). I wish to have a code that displays the
main worksheet and hides all target worksheets (since the values in
the weight column are blank) as long as no values have been entered.
Entering a value in the weight-column must display the corresponding
worksheet. Deleting or setting the value to 0 must hide the
corresponding worksheet again (conditionally/dynamically on changing
values). Any experience on this? Many thanks!
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,346
Default Hide/Unhide worksheets upon entries in a range of the main workshe

Here is the basic idea which you should modify according to your data:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim isect As Range
Set isect = Application.Intersect(Target, Range("F5:F10"))
If Not isect Is Nothing Then
If Target.Address = "$F$5" Then
If Target = "" Then
Worksheets("Sheet2").Visible = False
Else
Worksheets("Sheet2").Visible = True
End If
ElseIf Target.Address = "$F$6" Then
' more code ...
End If
End If
End Sub

1. To add this code to your file right click on the Master sheet tab and
choose View Code.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire


"ran58" wrote:

I have a workbook with 6 worksheets of the same format (name it target
1-6). In my main worksheet (name it assessment) I have an overview of
related values. In cells A5:A10 of the latter, I give a catch-word for
each target, which then will be displayed in the respecitive target
worksheet. In cells F5:F10 I give the weight of each target (e.g. 10,
20, or blank, if no weight). I wish to have a code that displays the
main worksheet and hides all target worksheets (since the values in
the weight column are blank) as long as no values have been entered.
Entering a value in the weight-column must display the corresponding
worksheet. Deleting or setting the value to 0 must hide the
corresponding worksheet again (conditionally/dynamically on changing
values). Any experience on this? Many thanks!

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Hide/Unhide worksheets upon entries in a range of the mainworkshe

On 21 Jul., 17:07, Shane Devenshire
wrote:
Here is the basic idea which you should modify according to your data:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim isect As Range
Set isect = Application.Intersect(Target, Range("F5:F10"))
If Not isect Is Nothing Then
If Target.Address = "$F$5" Then
If Target = "" Then
Worksheets("Sheet2").Visible = False
Else
Worksheets("Sheet2").Visible = True
End If
ElseIf Target.Address = "$F$6" Then
' more code ...
End If
End If
End Sub

1. To add this code to your file right click on the Master sheet tab and
choose View Code.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire

"ran58" wrote:
I have a workbook with 6 worksheets of the same format (name it target
1-6). In my main worksheet (name it assessment) I have an overview of
related values. In cells A5:A10 of the latter, I give a catch-word for
each target, which then will be displayed in the respecitive target
worksheet. In cells F5:F10 I give the weight of each target (e.g. 10,
20, or blank, if no weight). I wish to have a code that displays the
main worksheet and hides all target worksheets (since the values in
the weight column are blank) as long as no values have been entered.
Entering a value in the weight-column must display the corresponding
worksheet. Deleting or setting the value to 0 must hide the
corresponding worksheet again (conditionally/dynamically on changing
values). Any experience on this? Many thanks!


Hi Shane, many thanks for the code. As I am rather at the dummy user's
side of VB, I wonder whether you could please check the code again.
Until now, the code does not effect anything. Many thanks for your
assistance!

Private Sub Worksheet_Change(ByVal Target As Range)

Dim isect As Range

Set isect = Application.Intersect(Target, Range("F5:F10"))

If Not isect Is Nothing Then

If Target.Address = "$F$5" Then

If Target = "" Then

Worksheets("Ziel1").Visible = False

Else

Worksheets("Ziel1").Visible = True

End If

ElseIf Target.Address = "$F$6" Then

If Target = "" Then

Worksheets("Ziel2").Visible = False

Else

Worksheets("Ziel2").Visible = True

End If

ElseIf Target.Address = "$F$7" Then

If Target = "" Then

Worksheets("Ziel3").Visible = False

Else

Worksheets("Ziel3").Visible = True

End If

ElseIf Target.Address = "$F$8" Then

If Target = "" Then

Worksheets("Ziel4").Visible = False

Else

Worksheets("Ziel4").Visible = True

End If

ElseIf Target.Address = "$F$9" Then

If Target = "" Then

Worksheets("Ziel5").Visible = False

Else

Worksheets("Ziel5").Visible = True

End If

ElseIf Target.Address = "$F$10" Then

If Target = "" Then

Worksheets("Ziel6").Visible = False

Else

Worksheets("Ziel6").Visible = True

End If

' more code ...

End If

End If

End Sub

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10,124
Default Hide/Unhide worksheets upon entries in a range of the main workshe

This should do it. Be SURE it is placed in the sheet with the f5:f10 range

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo nomo
If Intersect(Target, Range("F5:F10")) Is Nothing Then Exit Sub
If Len(Application.Trim(Target)) 0 And IsNumeric(Target) Then
Sheets("ziel" & Target.Row - 4).Visible = True
Else
Sheets("Ziel" & Target.Row - 4).Visible = False
End If
nomo:
End Sub


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"ran58" wrote in message
...
On 21 Jul., 17:07, Shane Devenshire
wrote:
Here is the basic idea which you should modify according to your data:

Private Sub Worksheet_Change(ByVal Target As Range)
Dim isect As Range
Set isect = Application.Intersect(Target, Range("F5:F10"))
If Not isect Is Nothing Then
If Target.Address = "$F$5" Then
If Target = "" Then
Worksheets("Sheet2").Visible = False
Else
Worksheets("Sheet2").Visible = True
End If
ElseIf Target.Address = "$F$6" Then
' more code ...
End If
End If
End Sub

1. To add this code to your file right click on the Master sheet tab and
choose View Code.

--
If this helps, please click the Yes button.

Cheers,
Shane Devenshire

"ran58" wrote:
I have a workbook with 6 worksheets of the same format (name it target
1-6). In my main worksheet (name it assessment) I have an overview of
related values. In cells A5:A10 of the latter, I give a catch-word for
each target, which then will be displayed in the respecitive target
worksheet. In cells F5:F10 I give the weight of each target (e.g. 10,
20, or blank, if no weight). I wish to have a code that displays the
main worksheet and hides all target worksheets (since the values in
the weight column are blank) as long as no values have been entered.
Entering a value in the weight-column must display the corresponding
worksheet. Deleting or setting the value to 0 must hide the
corresponding worksheet again (conditionally/dynamically on changing
values). Any experience on this? Many thanks!


Hi Shane, many thanks for the code. As I am rather at the dummy user's
side of VB, I wonder whether you could please check the code again.
Until now, the code does not effect anything. Many thanks for your
assistance!

Private Sub Worksheet_Change(ByVal Target As Range)

Dim isect As Range

Set isect = Application.Intersect(Target, Range("F5:F10"))

If Not isect Is Nothing Then

If Target.Address = "$F$5" Then

If Target = "" Then

Worksheets("Ziel1").Visible = False

Else

Worksheets("Ziel1").Visible = True

End If

ElseIf Target.Address = "$F$6" Then

If Target = "" Then

Worksheets("Ziel2").Visible = False

Else

Worksheets("Ziel2").Visible = True

End If

ElseIf Target.Address = "$F$7" Then

If Target = "" Then

Worksheets("Ziel3").Visible = False

Else

Worksheets("Ziel3").Visible = True

End If

ElseIf Target.Address = "$F$8" Then

If Target = "" Then

Worksheets("Ziel4").Visible = False

Else

Worksheets("Ziel4").Visible = True

End If

ElseIf Target.Address = "$F$9" Then

If Target = "" Then

Worksheets("Ziel5").Visible = False

Else

Worksheets("Ziel5").Visible = True

End If

ElseIf Target.Address = "$F$10" Then

If Target = "" Then

Worksheets("Ziel6").Visible = False

Else

Worksheets("Ziel6").Visible = True

End If

' more code ...

End If

End If

End Sub




  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 12
Default Hide/Unhide worksheets upon entries in a range of the mainworkshe

On 21 Jul., 19:36, "Don Guillett" wrote:
This should do it. Be SURE it is placed in the sheet with the f5:f10 range

Private Sub Worksheet_Change(ByVal Target As Range)
On Error GoTo nomo
If Intersect(Target, Range("F5:F10")) Is Nothing Then Exit Sub
If Len(Application.Trim(Target)) 0 And IsNumeric(Target) Then
Sheets("ziel" & Target.Row - 4).Visible = True
Else
Sheets("Ziel" & Target.Row - 4).Visible = False
End If
nomo:
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
"ran58" wrote in message

...

On 21 Jul., 17:07, Shane Devenshire
wrote:
Here is the basic idea which you should modify according to your data:


Private Sub Worksheet_Change(ByVal Target As Range)
Dim isect As Range
Set isect = Application.Intersect(Target, Range("F5:F10"))
If Not isect Is Nothing Then
If Target.Address = "$F$5" Then
If Target = "" Then
Worksheets("Sheet2").Visible = False
Else
Worksheets("Sheet2").Visible = True
End If
ElseIf Target.Address = "$F$6" Then
' more code ...
End If
End If
End Sub


1. To add this code to your file right click on the Master sheet tab and
choose View Code.


--
If this helps, please click the Yes button.


Cheers,
Shane Devenshire


"ran58" wrote:
I have a workbook with 6 worksheets of the same format (name it target
1-6). In my main worksheet (name it assessment) I have an overview of
related values. In cells A5:A10 of the latter, I give a catch-word for
each target, which then will be displayed in the respecitive target
worksheet. In cells F5:F10 I give the weight of each target (e.g. 10,
20, or blank, if no weight). I wish to have a code that displays the
main worksheet and hides all target worksheets (since the values in
the weight column are blank) as long as no values have been entered.
Entering a value in the weight-column must display the corresponding
worksheet. Deleting or setting the value to 0 must hide the
corresponding worksheet again (conditionally/dynamically on changing
values). Any experience on this? Many thanks!


Hi Shane, many thanks for the code. As I am rather at the dummy user's
side of VB, I wonder whether you could please check the code again.
Until now, the code does not effect anything. Many thanks for your
assistance!


Private Sub Worksheet_Change(ByVal Target As Range)


Dim isect As Range


Set isect = Application.Intersect(Target, Range("F5:F10"))


If Not isect Is Nothing Then


If Target.Address = "$F$5" Then


If Target = "" Then


Worksheets("Ziel1").Visible = False


Else


Worksheets("Ziel1").Visible = True


End If


ElseIf Target.Address = "$F$6" Then


If Target = "" Then


Worksheets("Ziel2").Visible = False


Else


Worksheets("Ziel2").Visible = True


End If


ElseIf Target.Address = "$F$7" Then


If Target = "" Then


Worksheets("Ziel3").Visible = False


Else


Worksheets("Ziel3").Visible = True


End If


ElseIf Target.Address = "$F$8" Then


If Target = "" Then


Worksheets("Ziel4").Visible = False


Else


Worksheets("Ziel4").Visible = True


End If


ElseIf Target.Address = "$F$9" Then


If Target = "" Then


Worksheets("Ziel5").Visible = False


Else


Worksheets("Ziel5").Visible = True


End If


ElseIf Target.Address = "$F$10" Then


If Target = "" Then


Worksheets("Ziel6").Visible = False


Else


Worksheets("Ziel6").Visible = True


End If


' more code ...


End If


End If


End Sub


Hi Don, your code is simply perfect! Thanks a lot!!! also to Shane,
which helped to clarify the problem....
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
take all data from several worksheets to one main worksheet? Kat Excel Discussion (Misc queries) 1 June 10th 09 07:58 PM
Viewing other worksheets in a main worksheet Brockwood Excel Discussion (Misc queries) 5 May 16th 09 05:33 AM
How do I hide and unhide worksheets in Excel 2007? Wayne from Ottawa Canada Excel Discussion (Misc queries) 0 August 14th 06 02:54 AM
how do i format from the main worksheet to the other worksheets s. Gqinvt00 New Users to Excel 2 June 26th 06 09:01 PM
Can I hide a worksheet and set a passwd to unhide it? puneetarora_12 Excel Worksheet Functions 1 July 24th 05 08:50 AM


All times are GMT +1. The time now is 10:26 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"