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
 

Some videos you may like

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

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,511

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
 

Watch MrExcel Video

Forum statistics

Threads
1,122,230
Messages
5,594,947
Members
413,953
Latest member
Arthur1471

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