Function qui ne fonctionne pas
Bonjour,
dans la fonction suivante je déclenche une erreur dès la première ligne :
Function new_position(FB, AUX, DCS, WS, FGT, MAN As Byte, position As String) As String
Dim STO, ASTL, STL, MAI As Boolean
Dim curCell As Range
'*****************************************
'Initialisation des variables
STO , ASTL, STL, MAI = False
curCell = ThisWorkbook.Sheets("Export_results_datas")
'************************************************
'Coordonnées minimum requis pour FRO P1 / P2 / P3 / P4 / P5 / P6
'****************************************************
'Test pour niveau STO
If position = "FRO" Then
If FB > CInt(curCell.Range("P2")) Then
If AUX > CInt(curCell.Range("Q2")) Then
If DCS > CInt(curCell.Range("R2")) Then
If WS > CInt(curCell.Range("S2")) Then
If FGT > CInt(curCell.Range("T2")) Then
If MAI > CInt(curCell.Range("U2")) Then
STO = True
End If
End If
End If
End If
End If
End If
End If
'Test pour niveau ASTL
If position = "FRO" Or position = "STO" Then
If FB > CInt(curCell.Range("P3")) Then
If AUX > CInt(curCell.Range("Q3")) Then
If DCS > CInt(curCell.Range("R3")) Then
If WS > CInt(curCell.Range("S3")) Then
If FGT > CInt(curCell.Range("T3")) Then
If MAI > CInt(curCell.Range("U3")) Then
ASTL = True
End If
End If
End If
End If
End If
End If
End If
'Test pour niveau STL
If position = "FRO" Or position = "STO" Or position = "ASTL" Then
If FB > CInt(curCell.Range("P4")) Then
If AUX > CInt(curCell.Range("Q4")) Then
If DCS > CInt(curCell.Range("R4")) Then
If WS > CInt(curCell.Range("S4")) Then
If FGT > CInt(curCell.Range("T4")) Then
If MAI > CInt(curCell.Range("U4")) Then
STL = True
End If
End If
End If
End If
End If
End If
End If
'Test pour niveau MAI
If position = "FRO" Or position = "STO" Or position = "ASTL" Then
If FB > CInt(curCell.Range("P5")) Then
If AUX > CInt(curCell.Range("Q5")) Then
If DCS > CInt(curCell.Range("R5")) Then
If WS > CInt(curCell.Range("S5")) Then
If FGT > CInt(curCell.Range("T5")) Then
If MAI > CInt(curCell.Range("U5")) Then
MAI = True
End If
End If
End If
End If
End If
End If
End If
If STO = True Then
result = "STO"
If ASTL = True Then
result = "ASTL"
If STL = True Then
result = "STL"
End If
End If
End If
If position = "MAI" Then
If STO = True Then
result = "STO"
If ASTL = True Then
result = "ASTL"
If STL = True Then
result = "STL"
End If
End If
End If
End If
'MsgBox ("F&B : " & CStr(FB) & vbCrLf & "Aux : " & CStr(AUX) & vbCrLf & _
' "WS : " & CStr(WS) & vbCrLf & "DCS : " & CStr(DCS) & vbCrLf & "FGT : " & CStr(FGT) & vbCrLf & _
' "Mai : " & CStr(MAI) & vbCrLf & "Position : " & CStr(position) & _
' "Resultat : " & result)
End Function
J'ai regardé je n'ai pas besoin de faire un "begin" comme avec VB normal....
L'erreur est :
"Compile error : Excpected Sub, Function or Property..."
Le code est assez bien commenté, mais comme vous pouvez le voir, je renvoie une liste d'arguments à tester en fonction d'un tableau dans la feuille et selon les critère et le résultats je passe mes booleans de false à true.
Merci d'avance
David
Bonsoir David,
A la place de :
STO , ASTL, STL, MAI = False
essais :
STO = False
ASTL = False
STL = False
MAI = False
Ho mince il est si "peu" puissant, j'avais pensé à ça mais je me suis dit non quand même...
Bon ok bien pris.
Merci bonne soirée
David
- Messages
- 4'094
- Excel
- 2021 FR 64 bits
- Inscrit
- 13/06/2016
- Emploi
- bénévole associations Goutte d'Or
Bonjour,
Noter également que STO, ASTL, et STL sont définies en variant et non en booléen.
Dim STO As Boolean, ASTL As Boolean, STL As Boolean, MAI As Boolean
Pour simplifier l'initilialisation de ces variables
STO = False: ASTL = False: STL = False: MAI = False