I have a VBA function that's running very slowly, and I'm looking for suggestions as to how to improve it. The context is that the sheet has multiple sets of rows called 'components', and this function is walking through them determining which ones should be visible and which should be hidden
Here's my (probably naive) implementation:
Sub tasks_update_component_visibility()
Dim rowIdx As Long
For rowIdx = 1 To ActiveSheet.UsedRange.Rows.Count Step 1
If Cells(rowIdx, "A").Value = "%Start" Then
Dim hide, enable, isHidden As Boolean
hide = Not Cells(rowIdx, ComponentShownColumnName).Value
disable = Not Cells(rowIdx, ComponentEnabledColumnName).Value
isHidden = Rows(rowIdx).EntireRow.Hidden
Rem If we're hidden now and we shouldn't be, we need to reset the
Rem component's contents before we show it
If isHidden And Not hide Then
reset_component (rowIdx)
End If
Rem Now hide or show the component appropriately
If (disable And Not isHidden) Or (hide <> isHidden) Then
rowIdx = hide_or_show_component(rowIdx, hide, disable)
End If
End If
Next rowIdx
End Sub
I don't think the implementation of reset_component or hide_or_show_component matters much, but I'll post them if they might.
Anybody have any suggestions?
Thanks,
Aaron
Bookmarks