Erreur d'exécution "13"

Bonjour,

j'ai un problème sur ma macro en Vba je voulais crée une variable pour modifier une adresse URL qui me permettrait de collecter des donnée s statistiques sur des cotations d'une société et je voulais le faire en tapant juste dans une cellule le nom de la société mais il me dis erreur d'exécution "13"? (feuille 3)

vous trouverez ci-joint le code et le fichier !

Merci beaucoup et bonne soirée

DAVSEAGLE

Sub livestock()
'
' livestock Macro
'

Dim Tickers As Integer
Tickers = Cells(2, 1)

'
    Application.CutCopyMode = False
    Application.CutCopyMode = False
    ActiveWorkbook.Worksheets.Add
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;https://fr.finance.yahoo.com/quote/" & "Tickers" & "/key-statistics?p=" & "Tickers", _
        Destination:=Range("$A$5"))
        .CommandType = 0
        .Name = "key-statistics?p=AAPL"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlOverwriteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 1
        .WebSelectionType = xlEntirePage
        .WebFormatting = xlWebFormattingNone
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
    ActiveWindow.SmallScroll Down:=48
    Range("B74").Select
    Selection.Copy
    Sheets("Feuil1").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = ""
    Sheets("Feuil2").Select
    Selection.Copy
    Sheets("Feuil1").Select
    ActiveSheet.Paste Link:=True
    Sheets("Feuil2").Select
End Sub
19live-stock.xlsm (33.59 Ko)

Bonjour,

en modifiant cette ligne en commentaire, tout roule.

'        .CommandType = 0

j'ai bien mis pour l'erreur " '.CommandType = 0" et ca ne fonctionne toujours pas pour la feuille 3

Sub livestock()
'
' livestock Macro
'

Dim Tickers As Integer
Tickers = Cells(2, 1)

'
    Application.CutCopyMode = False
    Application.CutCopyMode = False
    ActiveWorkbook.Worksheets.Add
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;https://fr.finance.yahoo.com/quote/" & "Tickers" & "/key-statistics?p=" & "Tickers", _
        Destination:=Range("$A$5"))
        '.CommandType = 0
        .Name = "key-statistics?p=AAPL"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlOverwriteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 1
        .WebSelectionType = xlEntirePage
        .WebFormatting = xlWebFormattingNone
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
    ActiveWindow.SmallScroll Down:=48
    Range("B74").Select
    Selection.Copy
    Sheets("Feuil1").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    ActiveCell.FormulaR1C1 = ""
    Sheets("Feuil2").Select
    Selection.Copy
    Sheets("Feuil1").Select
    ActiveSheet.Paste Link:=True
    Sheets("Feuil2").Select
End Sub

bonjour

salut Isabelle

as-tu essayé Power Query pour récupérer des données depuis un site ?

bonjour,

mon code vba est enregistré et j'ai utilisé l'importation via power query (donnée) et j'aimerai juste modifié ma macro feuille 3 pour que ce que je tape en a2 feuille 3 modifie l'adresse url et aille chercher les données automatiquement.

merci

Bonjour,

à tester,

Dim Tickers As String
Tickers = Sheets("Feuil3").Cells(2, 1)

    Application.CutCopyMode = False
    ActiveWorkbook.Worksheets.Add
    With ActiveSheet.QueryTables.Add(Connection:= _
        "URL;https://fr.finance.yahoo.com/quote/" & Tickers & "/key-statistics?p=" & Tickers, Destination:=Range("$A$1"))
Rechercher des sujets similaires à "erreur execution"