Stop Screen Refresh VBA

surkdidat

Well-known Member
Joined
Oct 1, 2011
Messages
580
Office Version
  1. 365
Hi all

I have the following code, (there are multiple different options for Cell c15, which change the size of the screen based on the contents. However, the screen refreshes every time a value is entered. Is there a way, that upon changing the value in c15, it will update to the correct size, but then will not refresh/recalculate until a value is put in cell c22. (Two different examples of the code given, with the different sizes



Code:
 If Range("C15").Value = "AAAAA" Then
        Rows("18:19").EntireRow.Hidden = False
        
         ActiveWindow.Zoom = 80
   
   ActiveWindow.Zoom = 80
    iDesiredWidth = 660
    iDesiredHeight = 400
    
    
    With Application
        .WindowState = xlMaximized
        iMaxWidth = Application.Width
        iMaxHeight = Application.Height
        ' Adjust for starting point
        iMaxWidth = iMaxWidth - iStartX
        iMaxHeight = iMaxHeight - iStartY
        If iDesiredWidth > iMaxWidth Then
            iDesiredWidth = iMaxWidth
        End If
        If iDesiredHeight > iMaxHeight Then
            iDesiredHeight = iMaxHeight
        End If
        .WindowState = xlNormal
      
        .Width = iDesiredWidth
        .Height = iDesiredHeight
    End With


Code:
 If Range("C15").Value = "BBBBB" Then
    Application.ScreenUpdating =  False 
        Rows("19").EntireRow.Hidden = True
        Rows("18").EntireRow.Hidden = False
         
        
         ActiveWindow.Zoom = 80
   
   ActiveWindow.Zoom = 80
    iDesiredWidth = 620
    iDesiredHeight = 380
    With Application
        .WindowState = xlMaximized
        iMaxWidth = Application.Width
        iMaxHeight = Application.Height
        ' Adjust for starting point
        iMaxWidth = iMaxWidth - iStartX
        iMaxHeight = iMaxHeight - iStartY
        If iDesiredWidth > iMaxWidth Then
            iDesiredWidth = iMaxWidth
        End If
        If iDesiredHeight > iMaxHeight Then
            iDesiredHeight = iMaxHeight
        End If
        .WindowState = xlNormal
       
        .Width = iDesiredWidth
        .Height = iDesiredHeight
    End With
    End If
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

Forum statistics

Threads
1,214,649
Messages
6,120,732
Members
448,987
Latest member
marion_davis

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