VBA code stops working after a few minutes

Status
Not open for further replies.

alan myers

Board Regular
Joined
Oct 31, 2017
Messages
119
Office Version
  1. 365
Platform
  1. Windows
Private Sub Worksheet_Change(ByVal Target As Range)

Dim rng As Range
Dim cell As Range
Dim fr As Long
Dim lr As Long

' See if cell in cell B manually updated
Set rng = Intersect(Target, Range("B:B"))
If rng Is Nothing Then Exit Sub

' Loop through updated cells in column B
For Each cell In rng
' Capture rows to update
fr = Cells(cell.Row, "C").Value
lr = Cells(cell.Row, "D").Value
' Determine to hide or unhide rows
Select Case UCase(cell)
Case "Y"
Sheets("Cover Sheet").Rows(fr & ":" & lr).Hidden = True
Case "N"
Sheets("Cover Sheet").Rows(fr & ":" & lr).Hidden = False
End Select
Next cell

End Sub
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
on show hide tab if b2 = y, then take c2 value as start and d2 value as the end and on
cover sheet tab hides rows c2 thru d2, but if b2 = n, it unhides it
it checks this for b2 thru b196
 
Upvote 0
it works for me.
What do you mean by "stop working after few minutes"?
Does code work for the first run? second run?
At does not after few minutes from last run?
 
Upvote 0
Status
Not open for further replies.

Forum statistics

Threads
1,215,043
Messages
6,122,822
Members
449,096
Latest member
Erald

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