Auto Hide Rows

ExcelRoy

Well-known Member
Joined
Oct 2, 2006
Messages
2,540
Office Version
  1. 365
Platform
  1. Windows
Hi,

I am looking for some code to implement into a sheet

I would like to auto hide a row if in column "H" it shows "Inactive"

This would be within the ranges A1:H100

Many Thanks
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Try this: right click the sheet tab, select View Code and paste in

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Intersect(Target, Range("H1:H100")) Is Nothing Then Exit Sub
Target.EntireRow.Hidden = Target.Value = "Inactive"
End Sub
 
Upvote 0
Here is another way to look at it.

Though code above does seem more short and sweet :)

Code:
Public Sub FinIna()
 
Dim i As Integer
Range("A1").Select

Do While ActiveCell.Address <> Range("I1").Address
     For i = 1 To 100
          If UCase(Trim(ActiveCell.Offset(i - 1, 0).Value)) = "INACTIVE" Then
          Debug.Print (ActiveCell.Offset(i - 1, 0).Value)
          Selection.EntireColumn.Hidden = True
          End If
    Next i

ActiveCell.Offset(0, 1).Select
Loop
 
End Sub
 
Upvote 0
Hi Guys,

Are both solution supposed to be automatic?

It doesn't seem to work?

Thanks
 
Upvote 0
I've tested in a separate workbook and the code does work automatically.

What is the error message that you are getting?

Could you possibly post a screen shot of what the sheet looks like?
 
Upvote 0
Hi,

No error message just not working

yes VoG, formulas
 
Upvote 0
Try replacing my previous code with

Code:
Private Sub Worksheet_Calculate()
Dim i As Long
Application.ScreenUpdating = False
For i = 1 To 100
    Rows(i).Hidden = Range("H" & i).Value = "Inactive"
Next i
Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,596
Messages
6,179,807
Members
452,944
Latest member
2558216095

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