Macro Freezes Excel, second time it's run in the file

purook02

New Member
Joined
Dec 21, 2015
Messages
21
Why does this happen or what is this telling me is wrong? copde in red bold underlined is apparently the cause of the freezing the second time i run my macro.

1638378341664.png


Private Sub Worksheet_Change(ByVal Target As Range)
Dim RowCnt As Long
Dim BeginRow As Long
Dim EndRow As Long
Dim ChkCol As Long
Dim Rng As Range



Set Rng = Range("B10")


If Target.Cells.Count > 1 Then Exit Sub
If Intersect(Target, Rng) Is Nothing Then Exit Sub
BeginRow = 11
EndRow = 280
ChkCol = 4


Application.ScreenUpdating = False
Application.EnableEvents = False
With Sheets("COSTS-Single Model Matrix")




For RowCnt = BeginRow To EndRow
.Cells(RowCnt, ChkCol).EntireRow.Hidden = (.Cells(RowCnt, ChkCol).Value = 0)
Next RowCnt


End With


Application.ScreenUpdating = True
Application.EnableEvents = True
End Sub
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
I think within your for|next loop you will want to:

- unhide the desired row
- set your value, ie to 0
- hide the row again before looping to the next iteration.
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

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