Forum Discussion

bunny1580's avatar
bunny1580
Copper Contributor
Oct 18, 2023

i am trying to automatically hide or show rows depending on cell value in column O

i used this vba but it crashed my excel anyone who can thing of something i first used autofilter but then everytime i type somthing and move to a other cell excel has to load for 2 sec and it is not very handy to have it load 2 sec everytime so i went to vba but i cant get it to work because it has to work smoothly?


Private Sub Worksheet_Calculate()
Dim cell As Range
Dim rng As Range
Set rng = Me.Range("O:O") ' Monitors changes in column O

For Each cell In rng
If cell.Value = "HIDE" Then
cell.EntireRow.Hidden = True
ElseIf cell.Value = "SHOW" Then
cell.EntireRow.Hidden = False
End If
Next cell
End Sub

5 Replies

      • HansVogelaar's avatar
        HansVogelaar
        MVP

        bunny1580 

        Which cell(s) do the formula refer to?

        It might help if you could attach a small sample workbook demonstrating the problem (without sensitive data), or if that is not possible, make it available through OneDrive, Google Drive, Dropbox or similar.

Resources