Hi all,
Blow is my code to pull data out from a data base and then save the data to a worksheet. However, after the query is down and then switching between worksheets, my laptop loading becomes quite heavy. As I am trying to erase the data in the worksheet using clean contens, there is a message shows up which is "The range you are deleting is related to the query from external source. Except this range, would you like to delete this query? If you press "No", next time when updating the query, new data will be retrived to the worksheet". My data range is about 50 row x 78 columns.
Sheets("Raw Data").Select
Sheets("Raw Data").Range("A2:G50").Select
Selection.Clear
myCmd = "SELECT * FROM IWMES.DIMES_PPTU_PT_LTDFT Where (LOT_ID='" & LotArray(LotName - 1) & "') ORDER BY LOT_ID"
With ActiveSheet.QueryTables.Add(Connection:=myCnc1 & myCnc2 & myCnc3, Destination:=Range("A2"))
.CommandText = myCmd
.FieldNames = False
'.PreserveFormatting = True
.AdjustColumnWidth = False
.BackgroundQuery = False
.RefreshStyle = xlOverwriteCells
.Refresh
End With
Blow is my code to pull data out from a data base and then save the data to a worksheet. However, after the query is down and then switching between worksheets, my laptop loading becomes quite heavy. As I am trying to erase the data in the worksheet using clean contens, there is a message shows up which is "The range you are deleting is related to the query from external source. Except this range, would you like to delete this query? If you press "No", next time when updating the query, new data will be retrived to the worksheet". My data range is about 50 row x 78 columns.
Sheets("Raw Data").Select
Sheets("Raw Data").Range("A2:G50").Select
Selection.Clear
myCmd = "SELECT * FROM IWMES.DIMES_PPTU_PT_LTDFT Where (LOT_ID='" & LotArray(LotName - 1) & "') ORDER BY LOT_ID"
With ActiveSheet.QueryTables.Add(Connection:=myCnc1 & myCnc2 & myCnc3, Destination:=Range("A2"))
.CommandText = myCmd
.FieldNames = False
'.PreserveFormatting = True
.AdjustColumnWidth = False
.BackgroundQuery = False
.RefreshStyle = xlOverwriteCells
.Refresh
End With