As part of a recent Transport Science project, I've been given a sheet with data from 7094 car crashes. In an attempt to filter out only the relevant data - in this case crashes involving pedestrians, fatalities or serious injuries - I tried adapting a macro I found online.
This is my first time dabbling in VBA, although I have some undergrad experience in C and Java (just in case this proves relevant somehow). The code is as follows:
Sub HideRows()
BeginRow = 2
EndRow = 7095
ChkCol = 10
For RowCnt = BeginRow To EndRow
If Cells(RowCnt, ChkCol).Value > 0 Or Cells(RowCnt, ChkCol + 1).Value > 0 Or Cells(RowCnt, ChkCol + 2).Value > 0 Then
Rows(RowCnt).EntireRow.Hidden = False
Else
Rows(RowCnt).EntireRow.Hidden = True
End If
Next RowCnt
End Sub
The problem is it causes Excel to become unresponsive. I can see the macro is performing the intended function, but I can't save or regain control over the program at the end.
Struggling with this is wasting a lot of time and I've got a feeling the problem (and subsequent fix) is very, very simple - hopefully.
Any advice will be greatly appreciated.