VBA excel compile error : Expected Sub,Function, or property -
i trying run rungenkutta differential problem in excel vba program follows
sub rungenkutta() dim noofitrations integer dim n integer dim ii integer noofitrations = cells(2, 10) n = cells(3, 10) h = cells(3, 4) col = 8 x0 = cells(col, 9) y0 = cells(col, 10) = 1 noofitrations cells(7, 3) = x0 cells(7, 4) = y0 xn = x0 + h yn = y0 + cells(18, 3) ii mod n if ii = 0 col = col + 1 cells(col, 9) = xn cells(col, 10) = yn end if x0 = xn y0 = yn next end sub
but while running getting "vba excel compile error : expected sub,function, or property"
i not understanding shall run program
your problem mod operator. vba doesn't recognize syntax provided.
here documentation mod operator - http://msdn.microsoft.com/en-us/library/se0w9esz.aspx
th mod operator binary operator , requires 1 left , 1 right argument.
you need change
ii mod n
to
ii = mod n
here revised example provided.
sub rungenkutta() dim noofitrations integer dim n integer dim ii integer noofitrations = cells(2, 10) n = cells(3, 10) h = cells(3, 4) col = 8 x0 = cells(col, 9) y0 = cells(col, 10) = 1 noofitrations cells(7, 3) = x0 cells(7, 4) = y0 xn = x0 + h yn = y0 + cells(18, 3) ii = mod n if ii = 0 col = col + 1 cells(col, 9) = xn cells(col, 10) = yn end if x0 = xn y0 = yn next end sub
Comments
Post a Comment