[2007]formule moyenne dans un fichier calculé a partir de differents fichiers ouvert

PEX

XLDnaute Occasionnel
bonjours a tous,

depuis un moment je n'étais pas venu solliciter votre aide

voila je suis entrain de programmer une macro dans un module, je vous explique :

je souhaite dans un fichier A récupérer des donnés dans un fichier B mais je dois aussi faire la moyenne d'une colonne du fichier B en mettant le resultat dans une cellule du fichier A.
pour recuperer des infos dans les differentes cellules cela est fait, je n'arrive pas a integrer la formule dans mon code.

Code:
Sub ImporteDonnee()

Dim Principal As ThisWorkbook
Dim indice As Integer
Dim Repertoire As String
Dim Fichier As String
Dim Feuille As Worksheet
Dim Reponse As String


    Application.ScreenUpdating = True
    Set Principal = ThisWorkbook
    Repertoire = ThisWorkbook.Path + "\"
    
   
    
    ChDir Repertoire
    ' fichier = Dir("*.xlsx")
    Fichier = Dir(Repertoire + "\*.xls")


  On Error GoTo 0
    indice = 1
    Do While Fichier <> ""
        If Fichier <> Principal.Name Then
            Workbooks.Open Repertoire + "\" + Fichier
            
            
                Principal.Sheets("feuil1").Cells(indice, 1).Value = ActiveWorkbook.Path
                Principal.Sheets("feuil1").Cells(indice, 2).Value = ActiveWorkbook.Name
                Principal.Sheets("feuil1").Cells(indice, 3).Value = ActiveWorkbook.Sheets("feuil1").Cells(3, 2).Value
                Principal.Sheets("feuil1").Cells(indice, 4).Value = ActiveWorkbook.Sheets("Feuil1").FormulaR1C1 = "=AVERAGE(R[13]C[0]:R[1983]C[0])"
                       
            ActiveWorkbook.Close False
        End If
        Fichier = Dir
        indice = indice + 1
    Loop
    On Error Resume Next
    
End Sub

merci de votre aide

cordialement Pex
 

Discussions similaires

Réponses
6
Affichages
202

Statistiques des forums

Discussions
311 733
Messages
2 082 019
Membres
101 872
dernier inscrit
Colin T