Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
AVR AVR is offline
external usenet poster
 
Posts: 14
Default Worksheet change to control worksheet visibility

I am working in a sheet with 2 different data validation cells, named as
ranges "DV1" and "DV2" respectively. The only values for the cells are "Yes"
or "No". When one of those 2 cells changes, I want to hide or unhide other
sheets, based on the value in the changed cell. The following code is
running, but the visibility of the sheets is unaffected. What am I doing
wrong?

'Private Sub Worksheet_Change(ByVal Target As Range)
'
' a = Target.Address
' b = Target.Value
' x = Range("DV1").Address
' y = Range("DV2").Address
'
' If a = x Then
'
' If b = "Yes" Then
' Sheets("ShDV1A").Visible = True
' Sheets("ShDV1B").Visible = True
' Else
' Sheets("ShDV1A").Visible = False
' Sheets("ShDV1B").Visible = False
' End If
'
' ElseIf a = y Then
'
' If b = "Yes" Then
' Sheets("ShDV2A").Visible = True
' Sheets("ShDV2B").Visible = True
' Else
' Sheets("ShDV2A").Visible = False
' Sheets("ShDV2B").Visible = False
' End If
'
' End If
'
'
'End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 172
Default Worksheet change to control worksheet visibility

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A1").Value = "yes" Then
Sheets("Sheet2").Visible = False
Else
Sheets("Sheet2").Visible = True
End If

End Sub


Change to suit


Corey....



"AVR" wrote in message
...
I am working in a sheet with 2 different data validation cells, named as
ranges "DV1" and "DV2" respectively. The only values for the cells are
"Yes"
or "No". When one of those 2 cells changes, I want to hide or unhide
other
sheets, based on the value in the changed cell. The following code is
running, but the visibility of the sheets is unaffected. What am I doing
wrong?

'Private Sub Worksheet_Change(ByVal Target As Range)
'
' a = Target.Address
' b = Target.Value
' x = Range("DV1").Address
' y = Range("DV2").Address
'
' If a = x Then
'
' If b = "Yes" Then
' Sheets("ShDV1A").Visible = True
' Sheets("ShDV1B").Visible = True
' Else
' Sheets("ShDV1A").Visible = False
' Sheets("ShDV1B").Visible = False
' End If
'
' ElseIf a = y Then
'
' If b = "Yes" Then
' Sheets("ShDV2A").Visible = True
' Sheets("ShDV2B").Visible = True
' Else
' Sheets("ShDV2A").Visible = False
' Sheets("ShDV2B").Visible = False
' End If
'
' End If
'
'
'End Sub





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Worksheet change to control worksheet visibility

If I interpret your message correctly, you have assigned names to 2 cells
using names that are identical to a valid cell address.
Excel could be confused trying to determine if Range("DV1") refers to
the named range or to that actual cell.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"AVR"
wrote in message
I am working in a sheet with 2 different data validation cells, named as
ranges "DV1" and "DV2" respectively. The only values for the cells are "Yes"
or "No". When one of those 2 cells changes, I want to hide or unhide other
sheets, based on the value in the changed cell. The following code is
running, but the visibility of the sheets is unaffected. What am I doing
wrong?

'Private Sub Worksheet_Change(ByVal Target As Range)
' a = Target.Address
' b = Target.Value
' x = Range("DV1").Address
' y = Range("DV2").Address
'
' If a = x Then'
' If b = "Yes" Then
' Sheets("ShDV1A").Visible = True
' Sheets("ShDV1B").Visible = True
' Else
' Sheets("ShDV1A").Visible = False
' Sheets("ShDV1B").Visible = False
' End If
'
' ElseIf a = y Then'
' If b = "Yes" Then
' Sheets("ShDV2A").Visible = True
' Sheets("ShDV2B").Visible = True
' Else
' Sheets("ShDV2A").Visible = False
' Sheets("ShDV2B").Visible = False
' End If
'
' End If'
'End Sub



  #4   Report Post  
Posted to microsoft.public.excel.programming
AVR AVR is offline
external usenet poster
 
Posts: 14
Default Worksheet change to control worksheet visibility

Thanks for the post. Do you know why my code didn't work?

"Corey" wrote:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Range("A1").Value = "yes" Then
Sheets("Sheet2").Visible = False
Else
Sheets("Sheet2").Visible = True
End If

End Sub


Change to suit


Corey....



"AVR" wrote in message
...
I am working in a sheet with 2 different data validation cells, named as
ranges "DV1" and "DV2" respectively. The only values for the cells are
"Yes"
or "No". When one of those 2 cells changes, I want to hide or unhide
other
sheets, based on the value in the changed cell. The following code is
running, but the visibility of the sheets is unaffected. What am I doing
wrong?

'Private Sub Worksheet_Change(ByVal Target As Range)
'
' a = Target.Address
' b = Target.Value
' x = Range("DV1").Address
' y = Range("DV2").Address
'
' If a = x Then
'
' If b = "Yes" Then
' Sheets("ShDV1A").Visible = True
' Sheets("ShDV1B").Visible = True
' Else
' Sheets("ShDV1A").Visible = False
' Sheets("ShDV1B").Visible = False
' End If
'
' ElseIf a = y Then
'
' If b = "Yes" Then
' Sheets("ShDV2A").Visible = True
' Sheets("ShDV2B").Visible = True
' Else
' Sheets("ShDV2A").Visible = False
' Sheets("ShDV2B").Visible = False
' End If
'
' End If
'
'
'End Sub






  #5   Report Post  
Posted to microsoft.public.excel.programming
AVR AVR is offline
external usenet poster
 
Posts: 14
Default Worksheet change to control worksheet visibility

The actual range names I used are not valid cell addresses...just text. In
order to shorten the code for the post, I cut the names down and accidentally
created valid cell addresses. To avoid confusion, replace DV1 and DV2 with
DataVal1 and DataVal2. My question still stands. What is wrong with my
code? What I want the procedure to do is identify whether the change event
was triggered by one of the 2 named cells, and if so, which one...then make
the appropriate changes to the workbook by hiding / unhiding other sheets.
There are many other cells in the sheet which may change, but those events
should be ignored by the procedure.

Thanks for your help.

"Jim Cone" wrote:

If I interpret your message correctly, you have assigned names to 2 cells
using names that are identical to a valid cell address.
Excel could be confused trying to determine if Range("DV1") refers to
the named range or to that actual cell.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"AVR"
wrote in message
I am working in a sheet with 2 different data validation cells, named as
ranges "DV1" and "DV2" respectively. The only values for the cells are "Yes"
or "No". When one of those 2 cells changes, I want to hide or unhide other
sheets, based on the value in the changed cell. The following code is
running, but the visibility of the sheets is unaffected. What am I doing
wrong?

'Private Sub Worksheet_Change(ByVal Target As Range)
' a = Target.Address
' b = Target.Value
' x = Range("DV1").Address
' y = Range("DV2").Address
'
' If a = x Then'
' If b = "Yes" Then
' Sheets("ShDV1A").Visible = True
' Sheets("ShDV1B").Visible = True
' Else
' Sheets("ShDV1A").Visible = False
' Sheets("ShDV1B").Visible = False
' End If
'
' ElseIf a = y Then'
' If b = "Yes" Then
' Sheets("ShDV2A").Visible = True
' Sheets("ShDV2B").Visible = True
' Else
' Sheets("ShDV2A").Visible = False
' Sheets("ShDV2B").Visible = False
' End If
'
' End If'
'End Sub




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
Limit Visibility of a worksheet Tdahlman Excel Discussion (Misc queries) 1 March 12th 08 04:13 PM
worksheet image control appearance change (and back) with mousemov David Excel Programming 1 September 14th 05 02:03 PM
How to stop template worksheet visibility leaftye - ExcelForums.com Excel Programming 4 August 16th 05 08:07 PM
Reference to ActiveX control on worksheet requires full worksheet name Ian Ripsher[_5_] Excel Programming 3 June 25th 05 04:22 PM
Visibility Problem of Embedded Buttons in Worksheet Dave Peterson[_3_] Excel Programming 2 June 10th 04 03:39 AM


All times are GMT +1. The time now is 06:16 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"