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:
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.
I believe the error is somewhere within the red area, but I cannot find it!
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!