Bonjour Forum, voici ma function,

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
35
36
37
Function Conso(ByVal No_Conso As Integer, ByVal Annee As String) As Long
Dim sh As Worksheet
Dim val As Long
Dim Col As Integer
Dim montant As Long
Dim c As Range
Dim firstAddress As Range

Application.Volatile

val = 0
For Each sh In Sheets
    
    With sh
        If .Name = "BV" Or .Name = "Consolidation" Or .Name = "Master" Then
        
        Else
        Col = .Range("A3:AA3").Find(Annee, LookIn:=xlValues, lookat:=xlWhole).Column - 1
            
            With .Range("A1:A1000")
                
                Set c = .Find(No_Conso, LookIn:=xlValues, lookat:=xlWhole)
                If Not c Is Nothing Then
                    Set firstAddress = c.Address
                    Do
                        val = val + c.Offset(0, Col).Value
                        Set c = .FindNext(c)
                    Loop While Not c Is Nothing And c.Address <> firstAddress
                End If
            End With
        
        End If
    End With
Next

Conso = val
End Function
La ligne de code en rouge m'amène un imcompatibilité de type, mais pourtant mes variables "c" et "firstaddress" sont déclarer correctement.

Merci à l'avance!!