Summation with FOR loop

quan3165

New Member
Joined
May 1, 2011
Messages
3
Hi all,

I'm trying to use a FOR loop to sum all Sumn's for every n-value, which is my counter. I'm not familiar enough with VB syntax to know where I'm going wrong, but if anyone could shed some light on the subject, that would be greatly appreciated.

Here's the code:

Function Temp_A(x, y, T1)
Dim n As Integer, h, Sumn(1 To 31, 1 To 41)

Pi = 3.1415926536
W = 0.3
L = 0.4

For n = 1 To 9999 Step 1
h = Sumn(x, y)
Sumn(x, y) = (1 - Cos(n * Pi)) * WorksheetFunction.Sinh(n * Pi * (W - y) / L) * Sin(n * Pi * x / L) / (n * Pi * WorksheetFunction.Sinh(n * Pi * W / L))
Sumn = Sumn(x, y) + h
Next n

Temp_A = T1 * 2 * Sumn()

End Function

____________________
Thank you!
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

Forum statistics

Threads
1,224,583
Messages
6,179,682
Members
452,937
Latest member
Bhg1984

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top