VBA code stops working after a few minutes

Status
Not open for further replies.

alan myers

Board Regular
Joined
Oct 31, 2017
Messages
105
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

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college

My Aswer Is This

Well-known Member
Joined
Jul 5, 2014
Messages
19,116
Office Version
  1. 2013
Platform
  1. Windows
Tell me in words what you're trying to accomplish.
Please be specific.
 

alan myers

Board Regular
Joined
Oct 31, 2017
Messages
105
Office Version
  1. 365
Platform
  1. Windows
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
 

bebo021999

Well-known Member
Joined
Jul 14, 2011
Messages
1,799
Office Version
  1. 2016
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?
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
77,703
Office Version
  1. 365
Platform
  1. Windows
Duplicate so closed.
 
Status
Not open for further replies.

Forum statistics

Threads
1,176,081
Messages
5,901,278
Members
434,884
Latest member
ares0027

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