Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Hidden Row in seperate worksheet.

I am trying to hide a row when a cell in a different worksheet says no. Here
is my code:

Private Sub Worksheet_Calculate()
If Worksheets("Hospital").Range("B5").Value = "No" Then
Worksheets("Interview").Range("E9").EntireRow.Hidd en = True
If Worksheets("Hospital").Range("B5").Value = "Yes" Then
Worksheets("Interview").Range("E9").EntireRow.Hidd en = False
End Sub

It will not work. Can someone assist me?

thank you,

dan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default Hidden Row in seperate worksheet.

Dan,
For sure you are missing two "end If" statements:

Private Sub Worksheet_Calculate()
If Worksheets("Hospital").Range("B5").Value = "No" Then
Worksheets("Interview").Range("E9").EntireRow.Hidd en = True
End If
If Worksheets("Hospital").Range("B5").Value = "Yes" Then
Worksheets("Interview").Range("E9").EntireRow.Hidd en = False
End If
End Sub

Does it work with those inserted?

And if B5 has to be either Yes or No then:

Private Sub Worksheet_Calculate()
If Worksheets("Hospital").Range("B5").Value = "No" Then
Worksheets("Interview").Range("E9").EntireRow.Hidd en = True
Else
Worksheets("Interview").Range("E9").EntireRow.Hidd en = False
End If
End Sub


--
Ken Hudson


"Daniel R. Young" wrote:

I am trying to hide a row when a cell in a different worksheet says no. Here
is my code:

Private Sub Worksheet_Calculate()
If Worksheets("Hospital").Range("B5").Value = "No" Then
Worksheets("Interview").Range("E9").EntireRow.Hidd en = True
If Worksheets("Hospital").Range("B5").Value = "Yes" Then
Worksheets("Interview").Range("E9").EntireRow.Hidd en = False
End Sub

It will not work. Can someone assist me?

thank you,

dan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Hidden Row in seperate worksheet.

Hi Dan,

Your code works for me but requires that the sheet holding the code
recalculate.

It might suit your purposes better if you were to use the Worksheet_Change
event. Try putting the following into the Hospital sheet's code module:

Private Sub Worksheet_Change(ByVal Target As Range)
Worksheets("Interview").Rows(9).Hidden = _
UCase(Me.Range("B5").Value) = "NO"
End Sub


---
Regards,
Norman



"Daniel R. Young" wrote in message
...
I am trying to hide a row when a cell in a different worksheet says no.
Here
is my code:

Private Sub Worksheet_Calculate()
If Worksheets("Hospital").Range("B5").Value = "No" Then
Worksheets("Interview").Range("E9").EntireRow.Hidd en = True
If Worksheets("Hospital").Range("B5").Value = "Yes" Then
Worksheets("Interview").Range("E9").EntireRow.Hidd en = False
End Sub

It will not work. Can someone assist me?

thank you,

dan



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Hidden Row in seperate worksheet.

It does work, but only when I am in visual basic and I hit the play button.
It will not do it automactically. I want the row to hide once the cell=no.

dAn

"Ken Hudson" wrote:

Dan,
For sure you are missing two "end If" statements:

Private Sub Worksheet_Calculate()
If Worksheets("Hospital").Range("B5").Value = "No" Then
Worksheets("Interview").Range("E9").EntireRow.Hidd en = True
End If
If Worksheets("Hospital").Range("B5").Value = "Yes" Then
Worksheets("Interview").Range("E9").EntireRow.Hidd en = False
End If
End Sub

Does it work with those inserted?

And if B5 has to be either Yes or No then:

Private Sub Worksheet_Calculate()
If Worksheets("Hospital").Range("B5").Value = "No" Then
Worksheets("Interview").Range("E9").EntireRow.Hidd en = True
Else
Worksheets("Interview").Range("E9").EntireRow.Hidd en = False
End If
End Sub


--
Ken Hudson


"Daniel R. Young" wrote:

I am trying to hide a row when a cell in a different worksheet says no. Here
is my code:

Private Sub Worksheet_Calculate()
If Worksheets("Hospital").Range("B5").Value = "No" Then
Worksheets("Interview").Range("E9").EntireRow.Hidd en = True
If Worksheets("Hospital").Range("B5").Value = "Yes" Then
Worksheets("Interview").Range("E9").EntireRow.Hidd en = False
End Sub

It will not work. Can someone assist me?

thank you,

dan

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 38
Default Hidden Row in seperate worksheet.

Got it. Thank you.


"Norman Jones" wrote:

Hi Dan,

Your code works for me but requires that the sheet holding the code
recalculate.

It might suit your purposes better if you were to use the Worksheet_Change
event. Try putting the following into the Hospital sheet's code module:

Private Sub Worksheet_Change(ByVal Target As Range)
Worksheets("Interview").Rows(9).Hidden = _
UCase(Me.Range("B5").Value) = "NO"
End Sub


---
Regards,
Norman



"Daniel R. Young" wrote in message
...
I am trying to hide a row when a cell in a different worksheet says no.
Here
is my code:

Private Sub Worksheet_Calculate()
If Worksheets("Hospital").Range("B5").Value = "No" Then
Worksheets("Interview").Range("E9").EntireRow.Hidd en = True
If Worksheets("Hospital").Range("B5").Value = "Yes" Then
Worksheets("Interview").Range("E9").EntireRow.Hidd en = False
End Sub

It will not work. Can someone assist me?

thank you,

dan




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
2007 Worksheet, Hidden Columns, .CSV Format Saves Hidden Column Da Tammy Excel Discussion (Misc queries) 3 April 2nd 09 11:40 PM
How do I have seperate headers for seperate pages in 1 worksheet? JessicaDL Excel Discussion (Misc queries) 1 February 22nd 08 07:14 PM
Hidden Columns No Longer Hidden after Copying Worksheet? EV Nelson Excel Discussion (Misc queries) 1 December 6th 06 05:10 PM
How do I detect hidden worksheets or hidden data on a worksheet? Alice Excel Discussion (Misc queries) 4 August 24th 06 03:38 AM
Saving hidden data with a worksheet (preferably without using a hidden sheet) Dick Kusleika[_3_] Excel Programming 2 January 21st 04 04:39 PM


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