Function SumWithADO(fPath As String, fName As String, sName, cellRange As String, SumCol As Integer)
Dim myConn As ADODB.Connection, myCmd As ADODB.Command, myRS As ADODB.Recordset
Dim VPathFic As String
Dim I As Long, SumRng As Double
' Construction du chemin d'accès
If Right(fPath, 1) <> "\" Then fPath = fPath & "\"
VPathFic = fPath & fName
' Ouverture de la connexion et du recordset
Set myConn = New ADODB.Connection
myConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & VPathFic & ";" & _
"Extended Properties=""Excel 8.0;HDR=No;IMEX=1;"""
Set myCmd = New ADODB.Command
myCmd.ActiveConnection = myConn
myCmd.CommandText = "SELECT * from [" & sName & "$" & cellRange & "]"
Set myRS = New ADODB.Recordset
myRS.Open myCmd, , adOpenKeyset, adLockOptimistic
' Mettre à zéro la variable
SumRng = 0
' Se positionner sur le premier enregistrement
myRS.MoveFirst
' Restituer les données
For I = 1 To myRS.RecordCount
SumRng = SumRng + myRS(SumCol - 1)
' Enregistrement suivant
myRS.MoveNext
Next I
' Renvoyer la valeur à la fonction
SumWithADO = SumRng
' Fermer la connection
myConn.Close
Set myRS = Nothing
Set myCmd = Nothing
Set myConn = Nothing
End Function