Hide/Unhide rows - Application.CalculateFullRebuild replacement

otrava18

Board Regular
Joined
Feb 11, 2018
Messages
61
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 ?

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 !
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.

Forum statistics

Threads
1,215,001
Messages
6,122,648
Members
449,092
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top