1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| '@xfilename : nom du fichier
'@xlpath : chemin d'accès
Public Function consolidation(xlFileName As String, xlPath As String)
Dim ...'ce dont tu as besoin : def des colonnes de ta feuille etc
iColID = GetColumnMatchEx(xlFeuille, NomColonne)
....
'Se connecte à la feuille Excel
Set oCnn = connectToExcel(xlPath + "\" + xlFileName)
'Récupère les données de taux bonus
Set oRec = oCnn.OpenRecordSet("SELECT * FROM [" & xlFeuille.name & "$] ORDER BY [" & NomColonne& "] ASC")
If (Not oRec Is Nothing) Then
iRec = 0
Do While Not oRec.EOF
If Not IsNull(oRec.Fields(NomColonne).value) Then
'Met à jour la feuille
iRow = ChercherLastLigne 'récupère la dernière ligne de la feuille
If iRow > 0 Then
xlFeuille.Cells(iRow, iColID) = IIf(IsNull(oRec.Fields(NomColonne).value), "", oRec.Fields(NomColonne).value)
End If
End If
iRec = iRec + 1
frmChargement.setProgressBarValue iRec, oRec.RecordCount
oRec.moveNext
Loop
Set oRec = Nothing
End If
DoEvents
oCnn.Fermeture
Set oCnn = Nothing
xlFileName = Dir
End Function |
Partager