top of page

Sub importer()
'https://www.excel-pratique.com/fr/astuces_vba/importer_donnees_web
    
    Sheets("TEMP").Cells.Clear
    
    With Sheets("TEMP").QueryTables.Add(Connection:="URL;https://www.myfxbook.com/community/outlook/EURUSD" _
        , Destination:=Sheets("TEMP").Range("$A$1"))
        .Name = "exemple"
        .FieldNames = True
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = False
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .WebSelectionType = xlEntirePage
        .WebFormatting = xlWebFormattingAll
        .WebPreFormattedTextToColumns = True
        .WebConsecutiveDelimitersAsOne = True
        .WebSingleBlockTextImport = False
        .WebDisableDateRecognition = False
        .WebDisableRedirections = False
        .Refresh BackgroundQuery:=False
    End With
    
    compteur = 0
    
    For Ligne = 1 To 1000
        
        If Left(Sheets("TEMP").Cells(Ligne, 1), 6) = "Il y a" Then
            compteur = compteur + 1
            Sheets("ACCUEIL").Cells(compteur, 1) = Sheets("TEMP").Cells(Ligne - 1, 1).Hyperlinks(1).Address
            
            If compteur = 5 Then Exit For
        End If
                
    Next
    
End Sub

bottom of page