Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim strSearch As String
strSearch = Range("A2").Value
If Target.Address = "$A$2" Then
If (Left(strSearch, 4) = "http") Then
'If (Reference.Name = "test") Then
'MsgBox "la référence est inconnue et va être créée"
'Else
' Application.Goto Reference:="test"
' Selection.QueryTable.Delete
' Selection.ClearContents
' End If
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;" & strSearch & "", _
Destination:=Range("$D$2"))
.Name = "test"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 60
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End If
End If
End Sub