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
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
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
>
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
>
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
Sincerely,![]()
Please Login or Register to view this content.
Leith Ross
Last edited by Leith Ross; 11-03-2005 at 06:55 PM. Reason: Typo
Thanks all,
it works.
Bye
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks