Sur mon code vba, j'ai une erreur incomptaibilité de type sur la ligne " Call Requete_boursorama_PER(Sheets("URL_CAC40").Range("B" & i).Value, GetKeyDataFromList())" dans Collecte_PER() ; corriges moi le code complet pour ne plus qu'il y ait cette erreur :  
Function GetKeyDataFromList() As Collection
    Dim i As Integer
    Dim keyData As Collection
    Set keyData = New Collection

    ' Récupérer les mots clés et les noms d'onglets depuis l'onglet “listes”
    With Sheets("listes")
        For i = 2 To .Range("A" & Rows.Count).End(xlUp).Row
            keyData.Add Array(.Cells(i, "A").Value, .Cells(i, "B").Value), .Cells(i, "A").Value
        Next i
    End With

    Set GetKeyDataFromList = keyData
End Function

Function GetWebTablesRange(MON_URL As String) As Variant
    Dim tableEndIndex As Long
    Dim testQuery As Object
    
    On Error Resume Next
    tableEndIndex = 0
    
    Do
        ' Création de la requête Web pour tester l’index du tableau
        Set testQuery = ActiveWorkbook.Queries.Add(Name:="TestQuery", Formula:= _
             "let" & ChrW(13) & "" & ChrW(10) & "    Source = Web.Page(Web.Contents(" & MON_URL & "))," & ChrW(13) & "" & ChrW(10) & "    Data = Source{" & tableEndIndex & "}[Data]" & ChrW(13) & "" & ChrW(10) & "in" & ChrW(13) & "" & ChrW(10) & "    Data")
        If Err.Number <> 0 Then
            Exit Do
        End If
        On Error GoTo 0
        
        ' Supprimer la requête
        ActiveWorkbook.Queries("TestQuery").Delete
        
        tableEndIndex = tableEndIndex + 1

    Loop

    GetWebTablesRange = Range(0, tableEndIndex - 1)
End Function

Function FindTableByKeyword(MON_URL As String, keyword As String) As Range
    ' (Le code de la fonction Requete_boursorama_PER sera déplacé ici avec quelques modifications)
    
    ' (Supprimez les paramètres "keyData" et renommez "MOT_CHERCHE" en "keyword")
    
    Dim i As Integer
    Dim tableFound As Boolean
    Dim currentWebTable As Range

    For Each i In GetWebTablesRange(MON_URL)
        tableFound = False

        ' (Le code reste inchangé ici)

        Sheets("TEMP1").Range("B1").Value = keyword
        
        ' (Le code reste inchangé ici)

        If Sheets("TEMP1").Range("Resultat_PER").Value > 0 Then
            ' Le mot est trouvé
            tableFound = True

            ' Copier les données du tableau
            Set currentWebTable = Range("Table_999[#All]")
            
            ' Nettoyer le tableau et la requête
            On Error Resume Next
            ActiveSheet.ListObjects("Table_999").Delete
            On Error GoTo 0
            On Error Resume Next
            ActiveWorkbook.Queries("Table 999").Delete
            On Error GoTo 0

            Exit For ' Sortir de la boucle si le tableau avec le mot clé a été trouvé

        Else
            ' Nettoyer le tableau et la requête
            On Error Resume Next
            ActiveSheet.ListObjects("Table_999").Delete
            On Error GoTo 0
            On Error Resume Next
            ActiveWorkbook.Queries("Table 999").Delete
            On Error GoTo 0
        End If
    Next i

    Set FindTableByKeyword = currentWebTable
End Function


Sub Requete_boursorama_PER(MON_URL As String, keyData As Collection)
    Dim currentWebTable As Range
    Dim keyItem As Variant
    Dim SheetName As String

    ' Parcourir tous les mots clés
    For Each keyItem In keyData
        SheetName = keyItem(1)

        ' Trouver la première table qui contient le mot clé sur la page
        Set currentWebTable = FindTableByKeyword(MON_URL, keyItem(0))

        ' Copier les données du tableau
        If Not currentWebTable Is Nothing Then
            currentWebTable.Copy
            Sheets(SheetName).Range("A1").PasteSpecial Paste:=xlPasteValues
        End If
    Next keyItem
End Sub


Sub Collecte_PER()
Application.ScreenUpdating = False
Sheets("TEMP1").Visible = True
Sheets("TEMP2").Visible = True
Sheets("PER_Société").Visible = True

Dim Societe As String, Date_du_jour As String
Dim Der_Societe As Long, Der_Lig_Avant As Long, Der_Lig_Apres As Long

Date_du_jour = Format(Date, "dd/mm/yyyy")
Der_Societe = Sheets("URL_CAC40").Range("A" & Rows.Count).End(xlUp).Row

For i = 2 To Der_Societe
    Societe = Sheets("URL_CAC40").Range("A" & i).Value


 Call Requete_boursorama_PER(Sheets("URL_CAC40").Range("B" & i).Value, GetKeyDataFromList())

    If Sheets("TEMP2").Range("A1").Value <> "" Then
        Sheets("TEMP2").Range("A1").CurrentRegion.Copy

        With Sheets("PER_Société")
            Der_Lig_Avant = .Range("C" & .Rows.Count).End(xlUp).Row + 1
            .Range("C" & Der_Lig_Avant).PasteSpecial Paste:=xlPasteValues
            Der_Lig_Apres = .Range("C" & .Rows.Count).End(xlUp).Row

            .Range(.Cells(Der_Lig_Avant, 1), .Cells(Der_Lig_Apres, 1)).Value = Societe
            .Range(.Cells(Der_Lig_Avant, 2), .Cells(Der_Lig_Apres, 2)).Value = Date_du_jour
        End With
        Sheets("TEMP2").Range("A1").CurrentRegion.Clear

    End If
Next

Sheets("TEMP1").Visible = False
Sheets("TEMP2").Visible = False
Sheets("PER_Société").Visible = False

Application.ScreenUpdating = True

End Sub