Closed Thread
Results 1 to 6 of 6

using user defined constants

  1. #1
    ravi
    Guest

    using user defined constants

    Hello:

    when I run the following code Range A1 contaims "Name?" .What am I doing
    wrong ? Also in the for loop I would like to i to increment in steps of 0.1
    how do i do that ? they way I tried does not work ?Thanks in advance

    Ravi

    Sub EnterInfo()
    Dim i As Double
    Dim x As Integer
    Dim y As Integer
    Dim del As Range
    Dim cel As Range
    Set cel = Range("a1")
    Set del = Range("b1")
    x = 2
    y = 7
    For i = 1 To 10
    cel(i).Formula = "=SIN(x+y)"

    del(i).Value = i
    i = i + 0.1
    Next i

    End Sub


  2. #2
    Bob Phillips
    Guest

    Re: using user defined constants

    Try

    cel(i).Formula = "=SIN(" & x & "+" & y & ")"


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "ravi" <[email protected]> wrote in message
    news:[email protected]...
    > Hello:
    >
    > when I run the following code Range A1 contaims "Name?" .What am I doing
    > wrong ? Also in the for loop I would like to i to increment in steps of

    0.1
    > how do i do that ? they way I tried does not work ?Thanks in advance
    >
    > Ravi
    >
    > Sub EnterInfo()
    > Dim i As Double
    > Dim x As Integer
    > Dim y As Integer
    > Dim del As Range
    > Dim cel As Range
    > Set cel = Range("a1")
    > Set del = Range("b1")
    > x = 2
    > y = 7
    > For i = 1 To 10
    > cel(i).Formula = "=SIN(x+y)"
    >
    > del(i).Value = i
    > i = i + 0.1
    > Next i
    >
    > End Sub
    >




  3. #3
    ZGH
    Guest

    Re: using user defined constants

    For i = 1 To 10 step 0.1

    "ravi" <[email protected]> wrote in message
    news:[email protected]...
    > Hello:
    >
    > when I run the following code Range A1 contaims "Name?" .What am I doing
    > wrong ? Also in the for loop I would like to i to increment in steps of
    > 0.1
    > how do i do that ? they way I tried does not work ?Thanks in advance
    >
    > Ravi
    >
    > Sub EnterInfo()
    > Dim i As Double
    > Dim x As Integer
    > Dim y As Integer
    > Dim del As Range
    > Dim cel As Range
    > Set cel = Range("a1")
    > Set del = Range("b1")
    > x = 2
    > y = 7
    > For i = 1 To 10
    > cel(i).Formula = "=SIN(x+y)"
    >
    > del(i).Value = i
    > i = i + 0.1
    > Next i
    >
    > End Sub
    >




  4. #4
    ravi
    Guest

    Re: using user defined constants


    I tried

    For i=1 to 10 step 0.1

    It still does not work .Its does not increment properly. I get these values
    in range B1.

    1.4
    2.4
    3.4
    4.4
    5.5
    6.5
    7.5
    8.5
    9.5
    10

    I am trying to get these values in range B1

    0
    0.1
    0.2
    ..
    ..
    9.9
    10.0

    Should I add some sort of delay?

    Ravi

    Ravi
    "ZGH" wrote:

    > For i = 1 To 10 step 0.1
    >
    > "ravi" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hello:
    > >
    > > when I run the following code Range A1 contaims "Name?" .What am I doing
    > > wrong ? Also in the for loop I would like to i to increment in steps of
    > > 0.1
    > > how do i do that ? they way I tried does not work ?Thanks in advance
    > >
    > > Ravi
    > >
    > > Sub EnterInfo()
    > > Dim i As Double
    > > Dim x As Integer
    > > Dim y As Integer
    > > Dim del As Range
    > > Dim cel As Range
    > > Set cel = Range("a1")
    > > Set del = Range("b1")
    > > x = 2
    > > y = 7
    > > For i = 1 To 10
    > > cel(i).Formula = "=SIN(x+y)"
    > >
    > > del(i).Value = i
    > > i = i + 0.1
    > > Next i
    > >
    > > End Sub
    > >

    >
    >
    >


  5. #5
    Bob Phillips
    Guest

    Re: using user defined constants

    That is because i is the row index, so it must step in increments of 1. Try
    this (but it doesn't up x or y in the loop!)

    Sub EnterInfo()
    Dim i As Double
    Dim x As Integer
    Dim y As Integer
    Dim del As Range
    Dim cel As Range
    Set cel = Range("a1")
    Set del = Range("b1")
    x = 2: y = 7
    For i = 1 To 100
    cel(i).Formula = "=SIN(" & x & "+" & y & ")"
    del(i).Value = i
    Next i
    End Sub


    --

    HTH

    RP
    (remove nothere from the email address if mailing direct)


    "ravi" <[email protected]> wrote in message
    news:[email protected]...
    >
    > I tried
    >
    > For i=1 to 10 step 0.1
    >
    > It still does not work .Its does not increment properly. I get these

    values
    > in range B1.
    >
    > 1.4
    > 2.4
    > 3.4
    > 4.4
    > 5.5
    > 6.5
    > 7.5
    > 8.5
    > 9.5
    > 10
    >
    > I am trying to get these values in range B1
    >
    > 0
    > 0.1
    > 0.2
    > .
    > .
    > 9.9
    > 10.0
    >
    > Should I add some sort of delay?
    >
    > Ravi
    >
    > Ravi
    > "ZGH" wrote:
    >
    > > For i = 1 To 10 step 0.1
    > >
    > > "ravi" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Hello:
    > > >
    > > > when I run the following code Range A1 contaims "Name?" .What am I

    doing
    > > > wrong ? Also in the for loop I would like to i to increment in steps

    of
    > > > 0.1
    > > > how do i do that ? they way I tried does not work ?Thanks in advance
    > > >
    > > > Ravi
    > > >
    > > > Sub EnterInfo()
    > > > Dim i As Double
    > > > Dim x As Integer
    > > > Dim y As Integer
    > > > Dim del As Range
    > > > Dim cel As Range
    > > > Set cel = Range("a1")
    > > > Set del = Range("b1")
    > > > x = 2
    > > > y = 7
    > > > For i = 1 To 10
    > > > cel(i).Formula = "=SIN(x+y)"
    > > >
    > > > del(i).Value = i
    > > > i = i + 0.1
    > > > Next i
    > > >
    > > > End Sub
    > > >

    > >
    > >
    > >




  6. #6
    M. Authement
    Guest

    Re: using user defined constants

    I think the issue is using i for your 0.1 increments and your cell
    reference...cells cannot increment by 0.1.

    I did it this way and it worked fine:

    j = 0
    For i = 1 To 101
    cel(i).Formula = "=SIN(" & x & "+" & y & ")"
    del(i).Value = j
    j = j + 0.1
    Next i


    "ravi" <[email protected]> wrote in message
    news:[email protected]...
    >
    > I tried
    >
    > For i=1 to 10 step 0.1
    >
    > It still does not work .Its does not increment properly. I get these
    > values
    > in range B1.
    >
    > 1.4
    > 2.4
    > 3.4
    > 4.4
    > 5.5
    > 6.5
    > 7.5
    > 8.5
    > 9.5
    > 10
    >
    > I am trying to get these values in range B1
    >
    > 0
    > 0.1
    > 0.2
    > .
    > .
    > 9.9
    > 10.0
    >
    > Should I add some sort of delay?
    >
    > Ravi
    >
    > Ravi
    > "ZGH" wrote:
    >
    >> For i = 1 To 10 step 0.1
    >>
    >> "ravi" <[email protected]> wrote in message
    >> news:[email protected]...
    >> > Hello:
    >> >
    >> > when I run the following code Range A1 contaims "Name?" .What am I
    >> > doing
    >> > wrong ? Also in the for loop I would like to i to increment in steps of
    >> > 0.1
    >> > how do i do that ? they way I tried does not work ?Thanks in advance
    >> >
    >> > Ravi
    >> >
    >> > Sub EnterInfo()
    >> > Dim i As Double
    >> > Dim x As Integer
    >> > Dim y As Integer
    >> > Dim del As Range
    >> > Dim cel As Range
    >> > Set cel = Range("a1")
    >> > Set del = Range("b1")
    >> > x = 2
    >> > y = 7
    >> > For i = 1 To 10
    >> > cel(i).Formula = "=SIN(x+y)"
    >> >
    >> > del(i).Value = i
    >> > i = i + 0.1
    >> > Next i
    >> >
    >> > End Sub
    >> >

    >>
    >>
    >>




Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1