I am having a few issues where i run similar macros in different workbooks and i am trying to separate them as they may be running at the same time.
I read about ThisWorkbook functions and was wondering if i have to use it at the beginning of each reference to a sheet or cell or can it be set at the beginning of the macro.
I read about ThisWorkbook functions and was wondering if i have to use it at the beginning of each reference to a sheet or cell or can it be set at the beginning of the macro.
Code:
Sub Import()
Application.ScreenUpdating = False
Sheets("Track").Select
Range("Z1:AL100").Select
Selection.ClearContents
If ThisWorkbook.Sheets("Control").Range("AM2").Value = "" Then
GoTo Xit
Else
Range("Z2").Select
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & Sheets("Control").Range("AM2").Value, Destination:=Range( _
"$Z$2"))
.Name = False
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
Xit:
Application.ScreenUpdating = True
End If
Sheets("Control").Select
Clr: For I = 1 To ActiveWorkbook.Connections.Count
If ActiveWorkbook.Connections.Count = 0 Then Exit Sub
ActiveWorkbook.Connections.Item(I).Delete
I = I - 1
Next I
End Sub