hi all,
i have a code snippet which seems to run slow, any way to improve this code and add in worksheet unprotect for each ws in array and then reprotect each ws once columns are hidden?
Application.ScreenUpdating = False
Dim Assets As Variant
Dim Asset As Variant
Dim ThisSheet As Worksheet
Set ThisSheet = ActiveSheet
Assets = Array("Combined", "T1", "IT2", "T3", "T4", "T5", "T6", "T7", "T8", "T9", "T10", "T11", "T12", "T13", "T14", "T15", "T16", "T17", "T18")
For Each Asset In Assets
If Range("AG11").Value = False Then
Columns("AG").EntireColumn.Hidden = True
Else
Columns("AG").EntireColumn.Hidden = False
End If
If Range("AF11").Value = False Then
Columns("AF").EntireColumn.Hidden = True
Else
Columns("AF").EntireColumn.Hidden = False
End If
If Range("AH11").Value = False Then
Columns("AH").EntireColumn.Hidden = True
Else
Columns("AH").EntireColumn.Hidden = False
End If
Next Asset
ThisSheet.Select
End Sub
i have a code snippet which seems to run slow, any way to improve this code and add in worksheet unprotect for each ws in array and then reprotect each ws once columns are hidden?
Application.ScreenUpdating = False
Dim Assets As Variant
Dim Asset As Variant
Dim ThisSheet As Worksheet
Set ThisSheet = ActiveSheet
Assets = Array("Combined", "T1", "IT2", "T3", "T4", "T5", "T6", "T7", "T8", "T9", "T10", "T11", "T12", "T13", "T14", "T15", "T16", "T17", "T18")
For Each Asset In Assets
If Range("AG11").Value = False Then
Columns("AG").EntireColumn.Hidden = True
Else
Columns("AG").EntireColumn.Hidden = False
End If
If Range("AF11").Value = False Then
Columns("AF").EntireColumn.Hidden = True
Else
Columns("AF").EntireColumn.Hidden = False
End If
If Range("AH11").Value = False Then
Columns("AH").EntireColumn.Hidden = True
Else
Columns("AH").EntireColumn.Hidden = False
End If
Next Asset
ThisSheet.Select
End Sub
Last edited: