I called to excel to bring in the sinh function and i keep getting an error.
code below
Sub Start()
End Sub
Sub heattransfer()
'Variable Declaration
Dim qty, qty2, L, w, T1, T2, x, y, pi, sinh, e As Double
Dim nmax, j, i, r As Integer
'acquiring variable values
T1 = Sheets("main").Cells(4, "D").Value
T2 = Sheets("main").Cells(5, "D").Value
L = Sheets("main").Cells(6, "D").Value
w = Sheets("main").Cells(7, "D").Value
x = Sheets("main").Cells(5, "G").Value
y = Sheets("main").Cells(5, "H").Value
nmax = Sheets("main").Cells(4, "J").Value
'bringing in excel function
sinh = WorksheetFunction.sinh()
pi = WorksheetFunction.pi()
'calculation
For i = 1 To nmax Step 1
'enter heat tansfer function here
qty = qty + (2 / (i * pi)) * (1 - (-1) ^ i) / sinh(i * pi * (w / L))
qty2 = qty
If i > 1 Then
e = Abs((qty - qty2) / qty)
If e <= Sheets("main").Cells(4, "K") Then
Exit For
End If
End If
Next i
Sheets("main").Cells(4, "M").Value = i
Sheets("main").Cells(4, "L").Value = qty
End Sub
code below
Sub Start()
End Sub
Sub heattransfer()
'Variable Declaration
Dim qty, qty2, L, w, T1, T2, x, y, pi, sinh, e As Double
Dim nmax, j, i, r As Integer
'acquiring variable values
T1 = Sheets("main").Cells(4, "D").Value
T2 = Sheets("main").Cells(5, "D").Value
L = Sheets("main").Cells(6, "D").Value
w = Sheets("main").Cells(7, "D").Value
x = Sheets("main").Cells(5, "G").Value
y = Sheets("main").Cells(5, "H").Value
nmax = Sheets("main").Cells(4, "J").Value
'bringing in excel function
sinh = WorksheetFunction.sinh()
pi = WorksheetFunction.pi()
'calculation
For i = 1 To nmax Step 1
'enter heat tansfer function here
qty = qty + (2 / (i * pi)) * (1 - (-1) ^ i) / sinh(i * pi * (w / L))
qty2 = qty
If i > 1 Then
e = Abs((qty - qty2) / qty)
If e <= Sheets("main").Cells(4, "K") Then
Exit For
End If
End If
Next i
Sheets("main").Cells(4, "M").Value = i
Sheets("main").Cells(4, "L").Value = qty
End Sub