EXCEL or VBA: Hide row based on cell value?

wageslave101

Board Regular
Joined
Jul 18, 2007
Messages
154
If an IF statement returns a FALSE can the entire ROW be hidden?

Code:
=IF($C$49="book1.xls", C63, FALSE)

:eek:

WageSlave101
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

wageslave101

Board Regular
Joined
Jul 18, 2007
Messages
154
That formula is in C10, so if the result is FALSE I'd like to hide all of ROW 10... if that's possible :)
 

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
Code to the sheet module
Code:
Private Sub Worksheet_Calculate()
With Range("c10")
     .EntireRow.Hidden = (.Value = False)
End With
End Sub
Edited: code
 

wageslave101

Board Regular
Joined
Jul 18, 2007
Messages
154

ADVERTISEMENT

That worked amazingly for such a small code bit :biggrin: thank you very much.

Is it possible to apply this to a range? For example if I want to run this for rows c10:c25?

WageSlave101
 

jindon

MrExcel MVP
Joined
Aug 21, 2004
Messages
16,995
try
Code:
Private Sub Worksheet_Calculate()
With Range("c10:c25")
     .EntireRow.Hidden = False
     On Error Resume Next
     .SpecialCells(xlFormulas,4).EntireRow.Hidden = True
End With
End Sub
 

Macropod

Retired Moderator
Joined
Aug 27, 2007
Messages
3,613

ADVERTISEMENT

or perhaps:

Code:
Private Sub Worksheet_Calculate()
Dim i As Integer
For i = 10 To 25
    With Cells(i, 3)
        .EntireRow.Hidden = (.Value = False)
    End With
Next i
End Sub
Cheers
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,156
Messages
5,835,703
Members
430,380
Latest member
Psalmysam

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
Top