Hiding Rows on a Second Sheet, based on the cell value on a First Sheet

mikeb7500

Board Regular
Joined
Jul 30, 2014
Messages
99
I thought I already posted this, but it said I was logged off, so I apologize if this question appears twice.

On sheet named "Proposal", if N7=0, I need sheet named "Closing Statement" Rows 6-24 to auto-hide.

If "Proposal" N7>0, I need the "Closing Statement" Rows 6-24 to un-hide.

Currently the cell N7 contains "=SUM(H7,L7,M7)" which determines the value as 0, or more than 0.

Really need some help on this one folks...Thanks in advance!
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
.
Paste this into the PROPOSAL sheet module:

Code:
Option Explicit


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Me.Range("N7").Value = 0 Then
        Sheet2.Rows("6:24").EntireRow.Hidden = True
    ElseIf Me.Range("N7").Value > 0 Then
        Sheet2.Rows("6:24").EntireRow.Hidden = False
    End If
End Sub
 
Upvote 0
Worked Great...Thanks!


Option Explicit


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Me.Range("N7").Value = 0 Then
Sheet2.Rows("6:24").EntireRow.Hidden = True
ElseIf Me.Range("N7").Value > 0 Then
Sheet2.Rows("6:24").EntireRow.Hidden = False
End If
End Sub


[/CODE][/QUOTE]
 
Upvote 0
.
Glad to help.

Sorry, I was mistaken. I set up a test workbook with two tabs...a Proposal Tab, and Sheet 2 Tab. I then pasted your code on the Proposal Tab. It just sits there...does nothing. Any ideas? I do appreciate your further help.

Option Explicit


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Me.Range("N7").Value = 0 Then
Sheet2.Rows("6:24").EntireRow.Hidden = True
ElseIf Me.Range("N7").Value > 0 Then
Sheet2.Rows("6:24").EntireRow.Hidden = False
End If
End Sub
 
Upvote 0
.
Try this .. paste into the PROPOSAL sheet module :

Code:
Option Explicit


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.Range("N7").Value = "=SUM(H7,L7,M7)"
    If Me.Range("N7").Value = 0 Then
        Sheet2.Rows("6:24").EntireRow.Hidden = True
    ElseIf Me.Range("N7").Value > 0 Then
        Sheet2.Rows("6:24").EntireRow.Hidden = False
    End If
End Sub
 
Upvote 0
I did, it asked me to name it, I named it HiddenRows, but still nothing. Any ideas?

Getting the following error, with this line of code yellowed

Sheet2.Rows("6:24").EntireRow.Hidden = True

Unable to set the Hidden property of the Range class


.
Try this .. paste into the PROPOSAL sheet module :

Code:
Option Explicit


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Me.Range("N7").Value = "=SUM(H7,L7,M7)"
    If Me.Range("N7").Value = 0 Then
        Sheet2.Rows("6:24").EntireRow.Hidden = True
    ElseIf Me.Range("N7").Value > 0 Then
        Sheet2.Rows("6:24").EntireRow.Hidden = False

 
    End If
End Sub
 
Upvote 0
.
That error in this circumstance usually means those rows are already hidden.

Try unhiding them, then run the macro again.

You can also (after unhiding those rows), add one more line to the macro in hopes of preventing that error again : On Error Resume Next

Code:
Option Explicit


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Me.Range("N7").Value = "=SUM(H7,L7,M7)"
    If Me.Range("N7").Value = 0 Then
        Sheet2.Rows("6:24").EntireRow.Hidden = True
    ElseIf Me.Range("N7").Value > 0 Then
        Sheet2.Rows("6:24").EntireRow.Hidden = False
    End If
End Sub
 
Last edited:
Upvote 0
I can send you the two sheet workbook if you'd like to take a look at it. Then, when it works, I can transfer to the project I'm working on. I'm sure you'll spot the problem quickly. mikeb7500@gmail.com Send me an email, and I'll attach and send back. Thanks!

.
That error in this circumstance usually means those rows are already hidden.

Try unhiding them, then run the macro again.

You can also (after unhiding those rows), add one more line to the macro in hopes of preventing that error again : On Error Resume Next

Code:
Option Explicit


Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
Me.Range("N7").Value = "=SUM(H7,L7,M7)"
    If Me.Range("N7").Value = 0 Then
        Sheet2.Rows("6:24").EntireRow.Hidden = True
    ElseIf Me.Range("N7").Value > 0 Then
        Sheet2.Rows("6:24").EntireRow.Hidden = False
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,909
Messages
6,175,312
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top