Results 1 to 2 of 2

Thread: Help - Urgently Needed

Hybrid View

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2006
    Posts
    5

    Exclamation Help - Urgently Needed

    Hi,

    I am having some trouble with the following piece of code:

    t = 0
    j = 3

    For i = 1 To 100

    t_m = t + i
    **Worksheets("workings").Range("j,j+1").Value = Call_Eur

    a = Log(s / x)
    b = (r - q + (0.5 * (sd ^ 2))) * t_m
    c = sd * (t_m ^ 0.5)
    d1 = (a + b) / c
    d2 = d1 - sd * (t_m ^ 0.5)

    Call_Eur = (s * Exp(-q * t_m) * Hcumnorm(d1)) - (x * Exp(-r * t_m) *
    Hcumnorm(d2))

    **Worksheets("workings").Range("J+1,J+1").Value = Call_Eur

    Next i

    I am having trouble with the lines marked with 2 **.

    I want the code to generate t_m and then score the values in some predetermined cells. Then, I want the code to use the values generated for t_m to calculate the values for Call_Eur, and then store the latter, once again, predetermined cells.

    VBA says that there is a bug with code that i use to store the generated values in the cells.

    Would anyone have an idea of what im doing wrong or how i could modify the code for it to do wot i want?

    Thanks in advance.

    AJ

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Help - Urgently Needed

    Welcome to VBForums!

    I have moved this thread to the appropriate forum - Office Development.

    The problem is that you are specifying ranges with names of "j,j+1" and "J+1,J+1", which are not valid (only things like "A1" or "A3:B4" are).

    To specify a cell by number, use something like this instead (row then column):
    Worksheets("workings").Cells(j+1, j).Value = Call_Eur

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width