Chapeau à celui qu i trouve

morest

XLDnaute Occasionnel
Bonjour à tous potentiel sauveurs :).

Voici le code qui me rend complètement dingue :

Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Not Application.Intersect(Target, Range("B10")) Is Nothing Then
    Range("b11") = "=(B22*B10*(B6/1000)^3)*60"
    Range("b12") = "=B11/((PI()*(B6/1000)^2)/4)/3600"
    Range("b13") = "=(B10/60)*PI()*(B6/1000)"
    Range("b14") = "=(B22*(B10*60)*(B6/1000)^3/3600)/(((DONNEES!B33/1000)^2*PI()/4)-((B6/1000)^2*PI()/4))"
    Range("b15") = "=(B22*(B10*60)*(B6/1000)^3/3600)/(((DONNEES!B33/1000)^2*PI()/4))"
    Range("b16") = "=(DONNEES!B17*B21*(B10/60)^3*(B6/1000)^5)/1000"

End If

If Not Application.Intersect(Target, Range("B11")) Is Nothing Then
    Range("b10") = "=AA11/(B22*60*(B6/1000)^3)"
    
    Range("b12") = "=B11/((PI()*(B6/1000)^2)/4)/3600"
    Range("b13") = "=(B10/60)*PI()*(B6/1000)"
    Range("b14") = "=(B22*(B10*60)*(B6/1000)^3/3600)/(((DONNEES!B33/1000)^2*PI()/4)-((B6/1000)^2*PI()/4))"
    Range("b15") = "=(B22*(B10*60)*(B6/1000)^3/3600)/(((DONNEES!B33/1000)^2*PI()/4))"
    Range("b16") = "=(DONNEES!B17*B21*(B10/60)^3*(B6/1000)^5)/1000"

End If

End Sub

Le but de ce code est de calculer 6 cellules en fonction d'une seule, simplement en changeant la valeur de la cellule.

Le problème est que je n'arrive pas à ne pas ce que les cellules interagissent entre elles. Je souhaite pouvoir trouvé un code permettant d'éviter ce problème.

Merci d'avance.
 

morest

XLDnaute Occasionnel
Re : Chapeau à celui qu i trouve

Voilà ce que sa version évoluée donne :

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$B$10" Then
    Range("B11") = "=(B22*B10*(B6/1000)^3)*60"
    Range("B12") = "=B11/((PI()*(B6/1000)^2)/4)/3600"
    Range("B13") = "=(B10/60)*PI()*(B6/1000)"
    Range("B14") = "=(B22*(B10*60)*(B6/1000)^3/3600)/(((DONNEES!B33/1000)^2*PI()/4)-((B6/1000)^2*PI()/4))"
    Range("B15") = "=(B22*(B10*60)*(B6/1000)^3/3600)/(((DONNEES!B33/1000)^2*PI()/4))"
    Range("B16") = "=(DONNEES!B17*B21*(B10/60)^3*(B6/1000)^5)/1000"
End If

If Target.Address = "$B$11" Then
    Range("AA50") = Range("b11").Value
    Range("b10") = "=AA50/(B22*60*(B6/1000)^3)"
    
    Range("B12") = "=AA50/((PI()*(B6/1000)^2)/4)/3600"
    Range("B13") = "=(B10/60)*PI()*(B6/1000)"
    Range("B14") = "=(B22*(B10*60)*(B6/1000)^3/3600)/(((DONNEES!B33/1000)^2*PI()/4)-((B6/1000)^2*PI()/4))"
    Range("B15") = "=(B22*(B10*60)*(B6/1000)^3/3600)/(((DONNEES!B33/1000)^2*PI()/4))"
    Range("B16") = "=(DONNEES!B17*B21*(B10/60)^3*(B6/1000)^5)/1000"
End If

If Target.Address = "$B$12" Then
    Range("AA51") = Range("b12").Value
    Range("b10") = "=AA51*3600*((PI()*(B6/1000)^2)/4)/(B22*60*(B6/1000)^3)"
    Range("B11") = "=(B22*B10*(B6/1000)^3)*60"

    Range("B13") = "=(B10/60)*PI()*(B6/1000)"
    Range("B14") = "=(B22*(B10*60)*(B6/1000)^3/3600)/(((DONNEES!B33/1000)^2*PI()/4)-((B6/1000)^2*PI()/4))"
    Range("B15") = "=(B22*(B10*60)*(B6/1000)^3/3600)/(((DONNEES!B33/1000)^2*PI()/4))"
    Range("B16") = "=(DONNEES!B17*B21*(B10/60)^3*(B6/1000)^5)/1000"
End If

End Sub

Celle-ci fonctionne mais son problème est qu'elle n'arrive pas à s'arreter. Comment regler ce problème? Merci encore
 

kjin

XLDnaute Barbatruc
Re : Chapeau à celui qu i trouve

Bonjour,
Code:
Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address = "$B$10" Then
    Application.EnableEvents = False
    Range("B11") = "=(B22*B10*(B6/1000)^3)*60"
    Range("B12") = "=B11/((PI()*(B6/1000)^2)/4)/3600"
    Range("B13") = "=(B10/60)*PI()*(B6/1000)"
    Range("B14") = "=(B22*(B10*60)*(B6/1000)^3/3600)/(((DONNEES!B33/1000)^2*PI()/4)-((B6/1000)^2*PI()/4))"
    Range("B15") = "=(B22*(B10*60)*(B6/1000)^3/3600)/(((DONNEES!B33/1000)^2*PI()/4))"
    Range("B16") = "=(DONNEES!B17*B21*(B10/60)^3*(B6/1000)^5)/1000"
    Application.EnableEvents = True
End If

If Target.Address = "$B$11" Then
    Application.EnableEvents = False
    Range("AA50") = Range("b11").Value
    Range("b10") = "=AA50/(B22*60*(B6/1000)^3)"
    Range("B12") = "=AA50/((PI()*(B6/1000)^2)/4)/3600"
    Range("B13") = "=(B10/60)*PI()*(B6/1000)"
    Range("B14") = "=(B22*(B10*60)*(B6/1000)^3/3600)/(((DONNEES!B33/1000)^2*PI()/4)-((B6/1000)^2*PI()/4))"
    Range("B15") = "=(B22*(B10*60)*(B6/1000)^3/3600)/(((DONNEES!B33/1000)^2*PI()/4))"
    Range("B16") = "=(DONNEES!B17*B21*(B10/60)^3*(B6/1000)^5)/1000"
    Application.EnableEvents = True
End If

If Target.Address = "$B$12" Then
    Application.EnableEvents = False
    Range("AA51") = Range("b12").Value
    Range("b10") = "=AA51*3600*((PI()*(B6/1000)^2)/4)/(B22*60*(B6/1000)^3)"
    Range("B11") = "=(B22*B10*(B6/1000)^3)*60"
    Range("B13") = "=(B10/60)*PI()*(B6/1000)"
    Range("B14") = "=(B22*(B10*60)*(B6/1000)^3/3600)/(((DONNEES!B33/1000)^2*PI()/4)-((B6/1000)^2*PI()/4))"
    Range("B15") = "=(B22*(B10*60)*(B6/1000)^3/3600)/(((DONNEES!B33/1000)^2*PI()/4))"
    Range("B16") = "=(DONNEES!B17*B21*(B10/60)^3*(B6/1000)^5)/1000"
    Application.EnableEvents = True
End If

Edit : salut Pierrot :), j'ai les doigts engourdis...

A+
kjin
 

Discussions similaires

Réponses
26
Affichages
1 K
Réponses
25
Affichages
1 K
Réponses
11
Affichages
1 K