+ Reply to Thread
Results 1 to 5 of 5

VB Sum n+1

  1. #1
    Registered User
    Join Date
    09-16-2005
    Posts
    32

    VB Sum n+1

    Hello all.
    could someone help me to do the following in a Macro.

    In cell A1, I have Number "1"

    I want to have :
    A2 = A1 + 1
    A3 = A2 + 1
    A4 = A3 + 1
    .....
    Axx = Axx-1 + 1

    Thanks in advance

    Herve

  2. #2
    Bob Phillips
    Guest

    Re: VB Sum n+1


    For i = 2 To n
    Cells(i,"A").Formula = "=A" & i-1
    Next i

    but it is not clear how to determine what n is, or how to calculate it (the
    xx in yhour example).

    --

    HTH

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


    "herve" <herve.1xxxxm_1131054902.5338@excelforum-nospam.com> wrote in
    message news:herve.1xxxxm_1131054902.5338@excelforum-nospam.com...
    >
    > Hello all.
    > could someone help me to do the following in a Macro.
    >
    > In cell A1, I have Number "1"
    >
    > I want to have :
    > A2 = A1 + 1
    > A3 = A2 + 1
    > A4 = A3 + 1
    > ....
    > Axx = Axx-1 + 1
    >
    > Thanks in advance
    >
    > Herve
    >
    >
    > --
    > herve
    > ------------------------------------------------------------------------
    > herve's Profile:

    http://www.excelforum.com/member.php...o&userid=27314
    > View this thread: http://www.excelforum.com/showthread...hreadid=482037
    >




  3. #3
    Don Guillett
    Guest

    Re: VB Sum n+1

    will this do?

    Sub addone()
    For i = 1 To 4
    Cells(i, 1) = i
    Next
    End Sub


    --
    Don Guillett
    SalesAid Software
    donaldb@281.com
    "herve" <herve.1xxxxm_1131054902.5338@excelforum-nospam.com> wrote in
    message news:herve.1xxxxm_1131054902.5338@excelforum-nospam.com...
    >
    > Hello all.
    > could someone help me to do the following in a Macro.
    >
    > In cell A1, I have Number "1"
    >
    > I want to have :
    > A2 = A1 + 1
    > A3 = A2 + 1
    > A4 = A3 + 1
    > ....
    > Axx = Axx-1 + 1
    >
    > Thanks in advance
    >
    > Herve
    >
    >
    > --
    > herve
    > ------------------------------------------------------------------------
    > herve's Profile:

    http://www.excelforum.com/member.php...o&userid=27314
    > View this thread: http://www.excelforum.com/showthread...hreadid=482037
    >




  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259
    Hello Herve,

    This macro allows you to select the cell you want. You can also drag and fill your range with this formula. When the value in A1 changes, so do all the dependent cells. Copy this macro into a VBA project module. To use it see the example.

    Example:
    A1 = 10
    A2 = Increment(A1)
    A3 = Increment(A2)
    A4 = Increment(A3)


    Results:
    A1 = 10
    A2 = 11
    A3 = 12
    A4 = 13


    Macor Code
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross
    Last edited by Leith Ross; 11-03-2005 at 06:55 PM. Reason: Typo

  5. #5
    Registered User
    Join Date
    09-16-2005
    Posts
    32
    Thanks all,
    it works.

    Bye

+ Reply to 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