Hello all,
I have a situation and i need experts advise. I have some data with formulas in a sheet. I copied this data in a new sheet (ex: in the new sheet in A51 cell i have a formula ='oldsheet'!A51). I try to hide rows where on column P (P3:P63) i have 0. You can see the above code. The problems appear now. If i use this code without Application.CalculateFullRebuild at the first hide i receive a value error on some cell and all P column has the same error and all rows are hide.
If i put Application.CalculateFullRebuild in the code , the rows are hide but my processor goes almost in full load and to hide 60 cells takes a lot.I have tried also with Application.Calculate and it is better but still takes 45 seconds to verify 60 cells and hide 50. Can you give me an advise to avoid this ?
Thank you very much !
I have a situation and i need experts advise. I have some data with formulas in a sheet. I copied this data in a new sheet (ex: in the new sheet in A51 cell i have a formula ='oldsheet'!A51). I try to hide rows where on column P (P3:P63) i have 0. You can see the above code. The problems appear now. If i use this code without Application.CalculateFullRebuild at the first hide i receive a value error on some cell and all P column has the same error and all rows are hide.
If i put Application.CalculateFullRebuild in the code , the rows are hide but my processor goes almost in full load and to hide 60 cells takes a lot.I have tried also with Application.Calculate and it is better but still takes 45 seconds to verify 60 cells and hide 50. Can you give me an advise to avoid this ?
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim xRg As Range
Application.ScreenUpdating = False
For Each xRg In Range("P3:P63")
If xRg.Value = 0 Then
xRg.EntireRow.Hidden = True
Application.CalculateFullRebuild
Else
xRg.EntireRow.Hidden = False
Application.CalculateFullRebuild
End If
Next xRg
Application.ScreenUpdating = True
End Sub
Thank you very much !