Sub insertion() For i = 0 To 5 ActiveCell.EntireRow.Insert Next i End Sub
result = "= " & f & " * (" & L & "/" & D & ") * (" & V & "^ 2 / (2 * 9.81))" ActiveCell.FormulaR1C1 = result
Function ln(ByVal X As Variant) As Double ln = log(X) * 2.3026 End Function Sub insertion() For i = 0 To 5 ActiveCell.EntireRow.Insert Next i End Sub Function haaland(ByVal epsilon As String, ByVal D As String, ByVal Re As String) As String haaland = "(1 / (-1.8 * log((6.9 /" & Re & ") + (" & epsilon & " / (" & D & "* 3.7)) ^ 1.11))) ^ 2" End Function Function Reynolds(ByVal D As String, ByVal Q As String, ByVal Nu As String) As String D = "(" & D & "/ 1000" S = "3.14 * " & D & "^ 2 / 4" Q = "(" & Q & "/ 3600" Reynolds = Q & "* " & S & "* " & D & "/ " & Nu End Function Sub pertes_sing() Cells(3, 1).select Call insertion ActiveCell.Offset(1, 0).Formulalocal = "Q" ActiveCell.Offset(2, 0).Formulalocal = "D" ActiveCell.Offset(3, 0).Formulalocal = "L" ActiveCell.Offset(1, 2).Formulalocal = "Epsilon" ActiveCell.Offset(3, 4).Formulalocal = "Dh" Dim Q As String Dim D As String Dim L As String Dim Nu As String Dim S As String Dim epsilon As String Dim V As String Dim Re As String Dim f As String Dim result As String Q = "(" & ActiveCell.Offset(1, 1).address & "/ 3600)" D = "(" & ActiveCell.Offset(2, 1).address & "/ 1000)" L = "(" & ActiveCell.Offset(3, 1).address & "/ 1000)" epsilon = ActiveCell.Offset(3, 1).address S = "3.14 * " & D & "^ 2 / 4" V = "(" & Q & "*" & S & ")" Nu = "1E-06" Re = Reynolds(D, Q, Nu) f = haaland(epsilon, D, Re) result = "= " & f & " * (" & L & "/" & D & ") * (" & V & "^ 2 / (2 * 9.81))" 'msgbox (result) ActiveCell.FormulaR1C1 = result End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionucfoutu, j'ai pas mis les guillemets, j'ai copier le retour de la console après un debug.print
result = f & " * (" & L & "/" & D & ") * (" & V & "^ 2 / (2 * 9,81))" ActiveCell.offset(4, 6).Formula = "=" & result
Sub insertion() For i = 0 To 5 ActiveCell.EntireRow.Insert Next i End Sub Function haaland(ByVal epsilon As String, ByVal D As String, ByVal Re As String) As String haaland = "(1 / (-1,8 * LOG10((6,9 /" & Re & ") + (" & epsilon & " / (" & D & "* 3,7)) ^ 1,11))) ^ 2" End Function Function Reynolds(ByVal D As String, ByVal Q As String, ByVal Nu As String) As String S = "3,14 * " & D & "^ 2 / 4" Reynolds = Q & "* " & S & "* " & D & "/ " & Nu End Function Sub pertes_sing() Cells(3, 1).select Call insertion ActiveCell.offset(1, 0).Formulalocal = "Q" ActiveCell.offset(2, 0).Formulalocal = "D" ActiveCell.offset(3, 0).Formulalocal = "L" ActiveCell.offset(1, 2).Formulalocal = "Epsilon" ActiveCell.offset(3, 4).Formulalocal = "Dh" Dim Q As String Dim D As String Dim L As String Dim Nu As String Dim S As String Dim epsilon As String Dim V As String Dim Re As String Dim f As String Dim result As String Q = "(" & ActiveCell.offset(1, 1).address & "/ 3600)" D = "(" & ActiveCell.offset(2, 1).address & "/ 1000)" L = "(" & ActiveCell.offset(3, 1).address & "/ 1000)" epsilon = ActiveCell.offset(1, 3).address S = "3,14 * (" & D & ")^ 2 / 4" V = "((" & Q & ")*(" & S & "))" Nu = "1E-06" Re = Reynolds(D, Q, Nu) f = haaland(epsilon, D, Re) result = f & " * (" & L & "/" & D & ") * (" & V & "^ 2 / (2 * 9,81))" ActiveCell.offset(3, 5).Formulalocal = "=" & result End Sub