VBA - Application.ScreenUpdate - Becoming "True" at some point?

goodysgotacuda

Board Regular
Joined
Jun 27, 2014
Messages
51
I have a code that runs for 5-20 seconds depending on how much data I import. With that imported data, I switch between sheets within the same workbook several times.

From what I have found, there are different methods for calling other sheets, some of which cause the Application.ScreenUpdate to change its value. I am using the following code to change sheets:
Rich (BB code):
Sheets("Temperature").Select

When I execute the macro, the ScreenUpdate = False works, then I see the "Temperature" sheet until the code ends. However, there are other Sheets("").select within the macro that doesn't seem to affect it.

Rich (BB code):
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
            
    'Unhide All Sheets
    For Each ws In ActiveWorkbook.Worksheets
    ws.Visible = xlSheetVisible
    Next ws
    ActiveSheet.Shapes("Arrow").Visible = False
    
    
    Sheets("Collected Data").Select

           
            Set Pete1 = Application.FileDialog(msoFileDialogFilePicker)
            With Pete1
                .InitialView = msoFileDialogViewDetails
                .InitialFileName = ThisWorkbook.Path
                .Filters.Add "Open File ", "*.txt", 1
                .ButtonName = "Import file"
                .Title = " Select .txt File for Import - Data"
                If .Show = -1 Then
                    FullPath = .SelectedItems(1)
            Else:
                    Sheets("Home").Select
                    Exit Sub
                End If
            End With
            With ActiveSheet.QueryTables.Add(Connection:= _
                "TEXT;" & FullPath, Destination:=Range("A1"))
            
...............
                End With
                    
            Selection.AutoFilter
            Selection.Columns.AutoFit
            With Selection
...............
            End With
            
            Range("A1").Select
            Range("C1:E1").Select
            Range(Selection, Selection.End(xlDown)).Select
            Selection.Copy
            Range("A1").Select
            
            Sheets("Temperature").Select
            
            Range("E1").Select
            ActiveSheet.Paste
            Range(Selection, Selection.End(xlDown)).Select
                Application.ScreenUpdating = False
                'Air Temp
                   
                Application.Run "ATPVBAEN.XLAM!Sample", ActiveSheet.Range("$E$2:$E$999999") _
               , ActiveSheet.Range("$B$2"), "P", 6, False

I believe the error is somewhere within the red area, but I cannot find it!
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.

Forum statistics

Threads
1,224,798
Messages
6,181,038
Members
453,013
Latest member
Shubashish_Nandy

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