Bonjour j'ai un le code suivant et je souhaiterai calculer mon A en fonction de AlphaP et ALphaM qui varie selon la sélection des combobox :

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
Public Function AlphaM(ByVal i As Integer, ByVal n As Byte, ByRef inpt As Range) As Variant
'Dim n As Byte
inpt = Worksheets("Feuil4").Range("A5:L25")
 
If cboTypParoi.Text = "Mur" Then
   If userform1.cboMatParoi.Text = "Béton dense" Then
   n = 3
   ElseIf userform1.cboMatParoi.Text = "Béton léger" Then
   n = 4
   ElseIf userform1.cboMatParoi.Text = "Parpaings pleins" Then
   n = 5
   ElseIf userform1.cboMatParoi.Text = "Parpaings creux" Then
   n = 6
   ElseIf cboMatParoi.Text = "Brique pleine" Then
   n = 8
   ElseIf userform1.cboMatParoi.Text = "Brique creuse" Then
   n = 7
   ElseIf userform1.cboMatParoi.Text = "Pan de bois" Then
   n = 9
   ElseIf userform1.cboMatParoi.Text = "Pan de fer" Then
   n = 10
   ElseIf userform1.cboMatParoi.Text = "Moellon" Then
   n = 11
   End If
End If
   AlphaM = inpt(i, n)
 
End 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
Public Function AlphaP(ByVal i As Integer, ByVal n As Byte, ByRef inpt As Range) As Variant
'Dim n As Byte
inpt = Worksheets("Feuil4").Range("A5:N25")
 
If cboTypParoi.Text = "Plancher" Then
   If Public Function AlphaP(ByVal i As Integer, ByVal n As Byte, ByRef inpt As Range) As Variant
'Dim n As Byte
inpt = Worksheets("Feuil4").Range("A5:N25")
 
If cboTypParoi.Text = "Plancher" Then
   If cboNatParoi.Text = "Dalle béton" Or cboNatParoi.Text = "Dalle béton sur poutrelle métallique" Or cboNatParoi.Text = "Dallage sur terre plein" _
   Or cboNatParoi.Text = "Bac collaborant" Or cboMatParoi.Text = "Chape béton" Then
   n = 3
   ElseIf cboNatParoi.Text = "Poutrelle métallique" Then
   n = 14
   ElseIf cboNatParoi.Text = "Plancher bois" Then
   n = 13
 
   End If
End If
   AlphaP = inpt(i, n)
 
End 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
 
Public Sub NiveauP()
  inpt = Worksheets("Feuil4").Range("A5:L25")
         Oupt = Worksheets("Feuil3").Range("A2:J22")
 
For i = 1 To 21
 
    Alpha_vitre = inpt(i, 12)                   
    PondA = inpt(i, 2)                            
 
    R = Oupt(i, 2)                                
    Lwatot = Oupt(i, 7)                          
    sigmaM = Oupt(i, 1)                           
 
 A = (AlphaP * ((2 * CDbl(UserForm1.TxtLargPlanch.Value) * CDbl(UserForm1.TxtLongPlanch.Value)))) + _
    ((AlphaM * CDbl(UserForm1.TxtHteurPlaf.Value) * 2 * (CDbl(UserForm1.TxtLargPlanch.Value) + CDbl(UserForm1.TxtLongPlanch.Value))) - _
    UserForm1.cboOuvAutLoc.Value - UserForm1.cboSurFen.Value) + _
    (Alpha_vitre * (100 - UserForm1.cboPourcOuv.Value) * UserForm1.cboSurFen.Value / 100) + UserForm1.cboOuvAutLoc.Value + _
    (UserForm1.cboPourcOuv.Value * UserForm1.cboSurFen.Value / 100)
 
''calculs....
end sub
je dois surement m'y prendre mal mais comment faire pour pouvoir appeler correctement les fonctions et bien les définir si ce n'est pas le cas? Merci.