Variable de contrôle for déjà utilisée
Marwen
-
Marwen -
Marwen -
Bonjour,
Je veux programmer deux différentes formules dans la colonne F selon les valeurs des cellules de la colonne E
Erreur de compilation : variable de contrôle for déjà utilisée
comment je peux corriger ce problème ? Merci
Sub calculamda()
' lamda Macro
For Each cell In Range("E8", "E100").Cells
If "cell.Value" < "2300" Then
For Each cell In Range("F8", "F100").Cells
cell.FormulaR1C1 = "=(64/RC[-1])"
Next
ElseIf "cell.value" > "2300" Then
For Each cell In Range("F8", "F100").Cells
cell.FormulaR1C1 = "=(0.316*POWER(RC[-1],-0.25))"
Next
End If
Next
End Sub
Je veux programmer deux différentes formules dans la colonne F selon les valeurs des cellules de la colonne E
Erreur de compilation : variable de contrôle for déjà utilisée
comment je peux corriger ce problème ? Merci
Sub calculamda()
' lamda Macro
For Each cell In Range("E8", "E100").Cells
If "cell.Value" < "2300" Then
For Each cell In Range("F8", "F100").Cells
cell.FormulaR1C1 = "=(64/RC[-1])"
Next
ElseIf "cell.value" > "2300" Then
For Each cell In Range("F8", "F100").Cells
cell.FormulaR1C1 = "=(0.316*POWER(RC[-1],-0.25))"
Next
End If
Next
End Sub
A voir également:
- Variable de contrôle for déjà utilisée
- Downloader for pc - Télécharger - Téléchargement & Transfert
- Fan controle - Télécharger - Optimisation
- Idm for mac - Télécharger - Téléchargement & Transfert
- Controle parental disney plus - Guide
- Copytrans heic for windows - Télécharger - Visionnage & Diaporama
1 réponse
yg_be
Messages postés
23541
Date d'inscription
Statut
Contributeur
Dernière intervention
Ambassadeur
1 584
bonjour, peut-être ainsi:
ou plutôt:
ou même:
par ailleurs, je me demande pourquoi tu ne mets pas directement une formule dans la colonne F, sans passer par du VBA:
Option Explicit Sub calculamda() ' lamda Macro Dim cell1 As Range, cell2 As Range For Each cell1 In Range("E8", "E100").Cells If cell1.Value < 2300 Then For Each cell2 In Range("F8", "F100").Cells cell2.FormulaR1C1 = "=(64/RC[-1])" Next cell2 ElseIf cell1.Value > 2300 Then For Each cell2 In Range("F8", "F100").Cells cell2.FormulaR1C1 = "=(0.316*POWER(RC[-1],-0.25))" Next cell2 End If Next cell1 End Sub
ou plutôt:
Sub calculamda2() ' lamda Macro Dim cell1 As Range For Each cell1 In Range("E8", "E100").Cells If cell1.Value < 2300 Then cell1.Offset(0, 1).FormulaR1C1 = "=(64/RC[-1])" Else cell1.Offset(0, 1).FormulaR1C1 = "=(0.316*POWER(RC[-1],-0.25))" End If Next cell1 End Sub
ou même:
Sub calculamda2() ' lamda Macro Dim cell1 As Range For Each cell1 In Range("E8", "E100").Cells If cell1.Value < 2300 Then cell1.Offset(0, 1) = 64 / cell1 Else cell1.Offset(0, 1) = 0.316 * cell1 ^ (-0.25) End If Next cell1 End Sub
par ailleurs, je me demande pourquoi tu ne mets pas directement une formule dans la colonne F, sans passer par du VBA:
=IF(RC[-1]<2300;64/RC[-1];0.316*POWER(RC[-1];-0.25))
Marwen
ça a marché , merci bien pour ton aide.