Modification d'un URL via excel (inputbox par ex)
Bonjour,
J'aimerai importer des données via un URL sur excel, ce qui fonctionne très bien avec le code suivant mais j'aimerai que l'utilisateur puisse sous excel modifier cet URL pour pouvoir accéder à des données différentes (la date fin par exemple définie dans l'URL par f=2012)
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://ichart.finance.yahoo.com/table.csv?s=%5EGSPC&a=00&b=1&c=2002&d=03&e=27&f=2012&g=m&ignore=.csv" _
, Destination:=Range("$A$1"))
.Name = "hp?s=%5EGSPC&b=1&a=00&c=2002&e=27&d=03&f=2012&g=m"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "15"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With |
J'ai essayé avec une inputbox comme suit:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
Dim anneefin as integer
anneefin = inputbox("saisir année de fin")
With ActiveSheet.QueryTables.Add(Connection:= _
"URL;http://ichart.finance.yahoo.com/table.csv?s=%5EGSPC&a=00&b=1&c=2002&d=03&e=27&f=2012&g=m&ignore=.csv" _
, Destination:=Range("$A$1"))
.Name = "hp?s=%5EGSPC&b=1&a=00&c=2002&e=27&d=03&f=anneefin&g=m"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = "15"
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With |
Mais en vain cela ne fonctionne pas !
Merci d'avance !