• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to generate numbers based on a cell value

Bomino

Member
Hello,
I need help with some VBA code.
When I type 6 in lets say cell A1, I would like to have:
D5=0
D6=1
D7=2
D8=3
D9=4
D10=5
D11=6

I hope it make sense:( . Any help will be greatly appreciated.
Thank you.
 
This should do
Code:
Sub test()
    [d5].Resize([a1] + 1) = Evaluate("row(1:" & [a1] + 1 & ")-1")
End Sub
 
Hi Bomino,

If you are okay with formula, try this in D5:

=IFERROR(MIN(IF($A$1>=ROW(A1)-1,ROW(A1)-1,"")),"")

or

=IF(AND(ROW(A1)-1<=$A$1,ISNUMBER($A$1)),ROW(A1)-1,"")

Copy down as required.

Regards,
 
Back
Top