C
Cerberus
I have a code I wrote to hide rows in a 2066 row spreadsheet but every time I
run the code, it takes about ten minutes and it hides rows all the way up to
row 7760. I have deleted everything in the spreadsheet beyond row 2066 and
cleared and possible fromating but it still hides everything to row 7760. Is
there a way to have it stop running after the last row that has a value?
Here is the code:
Private Sub Worksheet_Activate()
Dim HiddenRow&, RowRange As Range
'< Set the column that contains data >
Const DataCol As String = "A"
'****************************
ActiveWindow.DisplayZeros = False
Application.ScreenUpdating = False
For HiddenRow = 1 To ActiveSheet.UsedRange.Rows.Count
'Take the Value of the cells in column A of each row
If Val(Range(DataCol & HiddenRow).Value) <> 0 Then
'there's something in this row - don't hide
Rows(HiddenRow).EntireRow.Hidden = False
'Take the Length of the value in column A of each row
ElseIf Len(Range(DataCol & HiddenRow).Value) = 14 Then
'there's something in this row - don't hide
Rows(HiddenRow).EntireRow.Hidden = False
Else
'there's nothing in this row yet - hide it
Rows(HiddenRow).EntireRow.Hidden = True
End If
Next HiddenRow
Application.ScreenUpdating = True
End Sub
run the code, it takes about ten minutes and it hides rows all the way up to
row 7760. I have deleted everything in the spreadsheet beyond row 2066 and
cleared and possible fromating but it still hides everything to row 7760. Is
there a way to have it stop running after the last row that has a value?
Here is the code:
Private Sub Worksheet_Activate()
Dim HiddenRow&, RowRange As Range
'< Set the column that contains data >
Const DataCol As String = "A"
'****************************
ActiveWindow.DisplayZeros = False
Application.ScreenUpdating = False
For HiddenRow = 1 To ActiveSheet.UsedRange.Rows.Count
'Take the Value of the cells in column A of each row
If Val(Range(DataCol & HiddenRow).Value) <> 0 Then
'there's something in this row - don't hide
Rows(HiddenRow).EntireRow.Hidden = False
'Take the Length of the value in column A of each row
ElseIf Len(Range(DataCol & HiddenRow).Value) = 14 Then
'there's something in this row - don't hide
Rows(HiddenRow).EntireRow.Hidden = False
Else
'there's nothing in this row yet - hide it
Rows(HiddenRow).EntireRow.Hidden = True
End If
Next HiddenRow
Application.ScreenUpdating = True
End Sub