Bonjour à la communauté.

Je souhaite créer une procédure afin d'effectuer des vérifications sur le contenu d'une plage de cellule, dans chaque sheet d'un classeur.

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
 
sub MainProcedure
For Each wsh In ActiveWorkbook.Worksheets
For Each cell In wsh.Range("A1:" & LastCol & Lastrow)
FormatCheck (cell)
next cell
next wsh
end sud
 
Sub FormatCheck(cell As variant)
                    'Remove space after and before value
                    If CStr(cell) <> Trim(cell) Then S_ReportError
 
                    'Check for each cell if it contains a formula
                    If cell.HasFormula = True Then
                        S_ReportError 
                    End If
 
                    'Check for each cell if it contains forbiden character
                    RegexPattern (cell)
                    If regX > 0 Then
                        S_ReportError
                    End If
 
                    'Check for each cell if it contains more than 2 decimal
                    If IsNumeric(cell) Then
                       If InStr(CStr(cell), ".") > 0 Then
                         digit = Len(CStr(cell)) - InStr(CStr(cell), ".")
                    If digit > 4 Then S_ReportError
                    end if
                    end if
end sub

Lorsque l'argument "cell" est passé à la procédure FormatCheck, celui ci ne contient plus que la valeur de la cellule et non tout ses arguments(telle que la formule par exemple)
Nom : Capture1.PNG
Affichages : 109
Taille : 35,0 Ko
Nom : Capture3.PNG
Affichages : 104
Taille : 1,2 Ko
Dois-je changer le type de cell dans formatcheck pour conserver tout ses arguments ?
Sub FormatCheck(cell As Object or Range) ?
Dans ce cas j'ai une erreur 424 (Object required).

Merci d'avance pour votre aide.

Mandra.