Sub test()
ThisWorkbook.Sheets("Stat").Cells.Delete
With CreateObject("Adodb.Connection")
    .Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & ThisWorkbook.FullName & ";Extended Properties=""Excel 12.0;HDR=YES;"""
    Set rs = .Execute(SqlTirage)
    For i = 0 To rs.Fields.Count - 1
        ThisWorkbook.Sheets("Stat").Range("A1").Offset(, i) = rs(i).Name
    Next
    ThisWorkbook.Sheets("Stat").Range("A2").CopyFromRecordset rs
    Set rs = .Execute(SqlChance)
    With ThisWorkbook.Sheets("Stat")
        With .Cells(.Cells.Rows.Count, "A").End(xlUp).Offset(2)
            For i = 0 To rs.Fields.Count - 1
                .Offset(, i) = rs(i).Name
            Next
            .Offset(1).CopyFromRecordset rs
        End With
    End With
    
    .Close
End With
ThisWorkbook.Sheets("Stat").Select
End Sub
Function SqlTirage()
With ThisWorkbook.Sheets("Historique Tirage loto.")
SqlTirage = "Select Boules ,(count(Boules)/" & (.UsedRange.Rows.Count * 5) & ")*100 as [% tirages] from ("
SqlTirage = SqlTirage & vbCrLf & "Select [boule_1] as Boules from [Historique Tirage loto#$]"
SqlTirage = SqlTirage & vbCrLf & " union all Select [boule_2] as Boules from [Historique Tirage loto#$]"
SqlTirage = SqlTirage & vbCrLf & " union all Select [boule_3] as Boules from [Historique Tirage loto#$]"
SqlTirage = SqlTirage & vbCrLf & " union all Select [boule_4] as Boules from [Historique Tirage loto#$]"
SqlTirage = SqlTirage & vbCrLf & " union all Select [boule_5] as Boules from [Historique Tirage loto#$]"
SqlTirage = SqlTirage & vbCrLf & ") group by Boules order by Boules "
End With
End Function
Function SqlChance()
With ThisWorkbook.Sheets("Historique Tirage loto.")
    SqlChance = "Select [numero_chance] as [N Chance], (count([numero_chance])/" & (.UsedRange.Rows.Count) & ")*100 as [% tirages]  from [Historique Tirage loto#$] group by [numero_chance]"
End With
End Function