Problème VBA: appel de fonction dans la partie gauche doit renvo
bichon1998
Messages postés
9
Date d'inscription
Statut
Membre
Dernière intervention
-
bichon1998 Messages postés 9 Date d'inscription Statut Membre Dernière intervention -
bichon1998 Messages postés 9 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
J'ai réalisé ce code vba (je suis débutant en la matière) et lors du lancement de la macro, j'ai un problème d'appel de fonction (voir le titre) que je ne comprends pas.
Pourriez-vous me donner un coup de main svp ?
Sub quelAHT()
Dim i As Integer
Dim X(601) As Single
Dim ligne As Integer
Dim nom As String
Dim price As String
Dim minimum As Single
minimum = 101
For i = 7 To 601
If Cells(i, 30).Value <> "" And Cells(i, 24).Value <> "" And Cells(i, 23).Value <> "" And Cells(i, 26).Value <> "" And Cells(i, 2).Value = "AHT" And Cells(9, 40).Value >= Cells(i, 30).Value And Cells(10, 40).Value >= Cells(i, 24).Value And Cells(i, 23).Value <= Cells(11, 40).Value And Cells(12, 40).Value >= Cells(i, 26).Value Then
X(i) = 0.6 * (Cells(i, 30).Value / Cells(9, 40).Value) + 0.2 * (Cells(i, 24).Value / Cells(10, 40).Value) + 0.1 * (Cells(11, 40).Value / Cells(i, 23).Value) + 0.1 * (Cells(i, 26).Value / Cells(12, 40).Value)
Else: X(i) = 100
End If
If minimum > X(i) Then
minimum = X(i)
ligne = i
End If
Next i
nom = Cells(ligne, 1).Value
price = Cells(ligne, 16).Value
MsgBox "L'AHT le plus adapté est " & nom & " et son DayRate est de " & price & " ! "
Application.Run "'database AS.xls'!quelAHT"
End Sub
Merci d'avance !!
J'ai réalisé ce code vba (je suis débutant en la matière) et lors du lancement de la macro, j'ai un problème d'appel de fonction (voir le titre) que je ne comprends pas.
Pourriez-vous me donner un coup de main svp ?
Sub quelAHT()
Dim i As Integer
Dim X(601) As Single
Dim ligne As Integer
Dim nom As String
Dim price As String
Dim minimum As Single
minimum = 101
For i = 7 To 601
If Cells(i, 30).Value <> "" And Cells(i, 24).Value <> "" And Cells(i, 23).Value <> "" And Cells(i, 26).Value <> "" And Cells(i, 2).Value = "AHT" And Cells(9, 40).Value >= Cells(i, 30).Value And Cells(10, 40).Value >= Cells(i, 24).Value And Cells(i, 23).Value <= Cells(11, 40).Value And Cells(12, 40).Value >= Cells(i, 26).Value Then
X(i) = 0.6 * (Cells(i, 30).Value / Cells(9, 40).Value) + 0.2 * (Cells(i, 24).Value / Cells(10, 40).Value) + 0.1 * (Cells(11, 40).Value / Cells(i, 23).Value) + 0.1 * (Cells(i, 26).Value / Cells(12, 40).Value)
Else: X(i) = 100
End If
If minimum > X(i) Then
minimum = X(i)
ligne = i
End If
Next i
nom = Cells(ligne, 1).Value
price = Cells(ligne, 16).Value
MsgBox "L'AHT le plus adapté est " & nom & " et son DayRate est de " & price & " ! "
Application.Run "'database AS.xls'!quelAHT"
End Sub
Merci d'avance !!
A voir également:
- Un appel de fonction dans la partie gauche de l'affectation doit renvoyer variant ou object
- Excel compter cellule couleur sans vba - Guide
- Incompatibilité de type vba ✓ - Forum VB / VBA
- Erreur 13 incompatibilité de type VBA excel ✓ - Forum Excel
- Mkdir vba ✓ - Forum VB / VBA
- Dépassement de capacité vba ✓ - Forum Excel
Le debuggeur surligne en jaune la 1ere ligne du programme Sub quelAHT(). Je comprends pas...
je te répondrais un peu plus tard.
A+
Mais je me demande si ce n'est pas lié à mon code: If Cells( , ).Value <> " "
que je traduis par "Si ma cellule n'est pas vide", vu que pour moi le symbole <> signifie "est different de"
?
Application.Run "'database AS.xls'!quelAHT"
et je n'ai eu aucune erreur.
Le seul message reçu est
L'AHT le plus adapté est et son DayRate est de !