In excel I have a workbook with 4 sheets that get their data from the server.
Its a simple offcut viewer program in excel
every time I try to refresh the data Excel locks up, the cpu usage peaks to 100% and stays there until I close the application.
If I click the excel toolbar (refresh data) it still locks up.
Please help.
The code I use follows
Sheets(1).Select
Selection.QueryTable.Refre
sh BackgroundQuery:=False
Sheets(4).Select
Selection.QueryTable.Refre
sh BackgroundQuery:=False
Sheets(3).Select
Selection.QueryTable.Refre
sh BackgroundQuery:=False
Sheets(2).Select
Selection.QueryTable.Refre
sh BackgroundQuery:=False
The result - FREEZE
Then I tried the following
Sub DOIT2()
Sheets("MAIN").Select
Application.ScreenUpdating
= False
PROGRESSBAR.Show
PROGRESSBAR.Repaint
Sheets("Offcuts Coloured Board 16").Select
Cells.Select
Range("A1").Activate
Selection.ClearContents
Range("A1").Select
With ActiveSheet.QueryTables.Ad
d(Connecti
on:= _
"TEXT;Y:\NIKS TOOLS\MATERIALS\Offcuts Coloured Board 16.STD", Destination:= _
Range("A1"))
.Name = "Offcuts Coloured Board 16_1"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimi
ter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimite
r = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = "="
.TextFileColumnDataTypes = Array(1, 1)
.TextFileTrailingMinusNumb
ers = True
.Refresh BackgroundQuery:=False
End With
Sheets("MAIN").Select
Application.ScreenUpdating
= True
PROGRESSBAR.Hide
PROGRESSBAR1.Show
PROGRESSBAR1.Repaint
Application.ScreenUpdating
= False
Sheets("colourtop16").Sele
ct
Columns("A:C").Select
Range("A3").Activate
Selection.ClearContents
Selection.QueryTable.Delet
e
Range("A3").Select
With ActiveSheet.QueryTables.Ad
d(Connecti
on:= _
"TEXT;Y:\NIKS TOOLS\MATERIALS\Coloured Board Offcuts Top16.STD", Destination _
:=Range("A3"))
.Name = "Coloured Board Offcuts Top16"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimi
ter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimite
r = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = "="
.TextFileColumnDataTypes = Array(1, 1)
.TextFileTrailingMinusNumb
ers = True
.Refresh BackgroundQuery:=False
End With
Sheets("MAIN").Select
Application.ScreenUpdating
= True
PROGRESSBAR1.Hide
PROGRESSBAR2.Show
PROGRESSBAR2.Repaint
Application.ScreenUpdating
= False
'MDF AND PAINT BASE
Sheets("MDF READ").Select
Columns("A:C").Select
Range("A3").Activate
Selection.ClearContents
Selection.QueryTable.Delet
e
Range("A3").Select
With ActiveSheet.QueryTables.Ad
d(Connecti
on:= _
"TEXT;Y:\NIKS TOOLS\MATERIALS\Offcuts MDF Materials.STD", Destination _
:=Range("A3"))
.Name = "MDF Materials.STD"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimi
ter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimite
r = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = "="
.TextFileColumnDataTypes = Array(1, 1)
.TextFileTrailingMinusNumb
ers = True
.Refresh BackgroundQuery:=False
End With
Sheets("MAIN").Select
Application.ScreenUpdating
= True
PROGRESSBAR2.Hide
PROGRESSBAR3.Show
PROGRESSBAR3.Repaint
Application.ScreenUpdating
= False
Sheets("PAINT READ").Select
Columns("A:C").Select
Range("A3").Activate
Selection.ClearContents
Selection.QueryTable.Delet
e
Range("A3").Select
With ActiveSheet.QueryTables.Ad
d(Connecti
on:= _
"TEXT;Y:\NIKS TOOLS\MATERIALS\Offcuts Paint Base.STD", Destination _
:=Range("A3"))
.Name = "Offcuts Paint Base"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.TextFilePromptOnRefresh = False
.TextFilePlatform = 437
.TextFileStartRow = 1
.TextFileParseType = xlDelimited
.TextFileTextQualifier = xlTextQualifierDoubleQuote
.TextFileConsecutiveDelimi
ter = False
.TextFileTabDelimiter = True
.TextFileSemicolonDelimite
r = False
.TextFileCommaDelimiter = False
.TextFileSpaceDelimiter = False
.TextFileOtherDelimiter = "="
.TextFileColumnDataTypes = Array(1, 1)
.TextFileTrailingMinusNumb
ers = True
.Refresh BackgroundQuery:=False
End With
PROGRESSBAR3.Hide
Application.ScreenUpdating
= True
Sheets("MAIN").Select
End Sub
STILL NO GO??
Start Free Trial