Déclaration valeur initiale variable feuille
Bonjour,
J'aimerai savoir si ces deux paragraphes déclarent la même chose où sont ils différent ?
alphate = Sheets("calcul itératif OK").Range("I10")
Ete = Sheets("calcul itératif OK").Range("C23")
Ite = Sheets("calcul itératif OK").Range("C24")
entte = Sheets("calcul itératif OK").Range("C25")
fte = 0
With Sheets("calcul itératif OK")
alphate = Cells(10, I)
Ete = Celles(23, C)
Ite = Cells(24, C)
entte = Cells(25, C)
fte = 0
Car la première écriture est extrêmement lourde comparé à la deuxième.
Je dois déclarer plusieurs variables venant de feuilles différentes donc je dois être sur que la déclaration est bien écrite.
Merci d'avance.
Même chose sauf que, en utilisant with vous devez mettre un . devant cells (le point résume en quelque sorte l'objet feuille)
With Sheets("calcul itératif OK")
alphate = .Cells(10, I)
Ete = .Cells(23, C)
Ite = .Cells(24, C)
entte = .Cells(25, C)
fte = 0J'me disais bien que je devais mettre ce "." mais où ? ^^
merci encore ça m'avance.
D'habitude on les mets ailleurs les poing je sais, excel ne nous facilite pas la tache...
M'a pas l'air content de mon programme, erreur 400 ! pourtant rien de transcendant !
Sub boucle()
'--------------------------------------------------------------------------
' DECLARATION DE TOUTES LES VARIABLES
'--------------------------------------------------------------------------
Dim iter As Integer ' constantes boucle
Dim nbiter As Integer
'--------------------------------------------------------------------------
Dim fte As Integer ' constantes tête
Dim alphate As Integer
Dim Ete As Integer
Dim L1 As Integer
Dim Ite As Integer
Dim entte As Integer
Dim l As Integer
Dim ftei As Integer
'--------------------------------------------------------------------------
Dim fta As Integer ' constantes talon
Dim Eta As Integer
Dim alphata As Integer
Dim Ita As Integer
Dim entta As Integer
Dim D As Integer
Dim ftai As Integer
'--------------------------------------------------------------------------
Dim alltir As Integer ' constantes tirants
Dim Etir As Integer
Dim l0 As Integer
Dim sec As Integer
Dim alltir0 As Integer
'--------------------------------------------------------------------------
Dim alphapi As Integer ' constantes pile
Dim ftot As Integer
Dim ft As Integer
'--------------------------------------------------------------------------
Dim ecras As Integer ' constantes rondelles
Dim ep As Integer
Dim fsr As Integer
Dim S As Integer
'--------------------------------------------------------------------------
' DECLARATION DES VALEURS INITIALES
'--------------------------------------------------------------------------
iter = 2 ' numéro de départ d'itération
nbiter = 15 ' nombre d'itération choisie
With Sheets("calcul itératif OK")
alphata = .Cells(11, I)
Eta = .Cells(18, C)
Ita = .Cells(19, C)
entta = .Cells(20, C)
D = .Cells(21, C)
ftai = .Cells(7, H)
'--------------------------------------------------------------------------
alphate = .Cells(10, I)
Ete = .Cells(23, C)
Ite = .Cells(24, C)
entte = .Cells(25, C)
ftei = .Cells(6, H)
'--------------------------------------------------------------------------
alltir0 = .Cells(8, H)
Etir = .Cells(28, C)
sec = .Cells(29, C)
lo = .Cells(27, C)
'--------------------------------------------------------------------------
ft = .Cells(3, H)
alphapi = .Cells(9, I)
'--------------------------------------------------------------------------
ep = .Cells(15, H)
S = .Cells(13, H)
End With
With Sheets("Dimensionnement")
L1 = .Cells(8, N)
l = .Cells(8, O)
End With
'--------------------------------------------------------------------------
' Calcul itération 1 du tableau
'--------------------------------------------------------------------------
ecras = alphapi - (alphate + alphata)
fsr = ((ecras * ft) / S)
'--------------------------------------------------------------------------
' boucle à partir d'itération 2 du tableau (car à itération 1 fte et fta sont nulles !).
'--------------------------------------------------------------------------
While iter <= nbiter
' Calculs initiaux
ftot = ft + fsr
fte = ((-ftot / (2 * Ete * Ite)) * ((entte ^ 2 / 16 * (2 * L1 + l)) - (entte ^ 2 / 8 * (2 * L1 + l)) + (1 / 4 * (2 * L8 + l) * (L1 + l) ^ 2) + (1 / 6 * l ^ 2 * (L1 + l)) - (l ^ 3 / 24) - (1 / 3 * (L1 + l) ^ 3))) - ftei
fta = (-1 / (Eta * Ita) * ((ftot / 2 * entta ^ 3) / 48 - (ftot / 2 * D ^ 3) / 192 + (ftot / 2) * (D ^ 2 / 24 - entta ^ 2 / 8) * entta / 2)) - ftai
alltir = (((l0 * (ftot / 2)) / Etir * sec) - alltir0)
'---------------------------------------------------------------------------
ecras = alphapi - (alphate + alphata + alltir + fte + fta)
fsr = ((ecras * ftot) / S)
iter = iter + 1
Wend
MsgBox ftot
End Subsûrement une histoire de nombre à virgule mais rien y fait.
Ce sont les lignes de déclaration de variable qui font planté le code
par contre l'autre forme (la première) là ça plante pas ...
Bon en remplaçant toutes ces ligne ça fonctionne ! bizarre.
alphata = Sheets("calcul itératif OK").Range("I11")
Eta = Sheets("calcul itératif OK").Range("C18")
Ita = Sheets("calcul itératif OK").Range("C19")
entta = Sheets("calcul itératif OK").Range("C20")
D = Sheets("calcul itératif OK").Range("C21")
ftai = Sheets("calcul itératif OK").Range("H7")
'--------------------------------------------------------------------------
alphate = Sheets("calcul itératif OK").Range("I10")
Ete = Sheets("calcul itératif OK").Range("C23")
Ite = Sheets("calcul itératif OK").Range("C24")
entte = Sheets("calcul itératif OK").Range("C25")
ftei = Sheets("calcul itératif OK").Range("H6")
'--------------------------------------------------------------------------
alltir0 = Sheets("calcul itératif OK").Range("H8")
Etir = Sheets("calcul itératif OK").Range("C28")
sec = Sheets("calcul itératif OK").Range("C29")
lo = Sheets("calcul itératif OK").Range("C27")
'--------------------------------------------------------------------------
ft = Sheets("calcul itératif OK").Range("H3")
alphapi = Sheets("calcul itératif OK").Range("I9")
'--------------------------------------------------------------------------
ep = Sheets("calcul itératif OK").Range("H15")
S = Sheets("calcul itératif OK").Range("H13")
'--------------------------------------------------------------------------
L1 = Sheets("Dimensionnement").Range("N8")
l = Sheets("Dimensionnement").Range("O8")