ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   simple loop needed please (https://www.excelbanter.com/excel-discussion-misc-queries/263164-simple-loop-needed-please.html)

Alan

simple loop needed please
 
basically

i want the macro to enter values 1 to 5 for range g2:g6
then move onto row h2:h6 and start with 2 and place i and the bottom

so it should look like this

Column G Column h Column i
1 2 3
2 3 4
3 4 5
4 5 1
5 1 2

which then i can create a bigger range from G to P


can you help, i just can't work it out i've got 1 to 5 in every row but its
not what i want



Per Jessen

simple loop needed please
 
Hi

This should do it:

Sub aaa()
Dim StartCell As Range

Set StartCell = Range("G2")
For col = 0 To 9
MyVal = MyVal + 1
If MyVal 5 Then MyVal = 1
For r = 1 To 5
StartCell.Offset(r, col) = MyVal
MyVal = MyVal + 1
If MyVal 5 Then MyVal = 1
Next
Next
End Sub


Regards,
Per

"Alan" skrev i meddelelsen
...
basically

i want the macro to enter values 1 to 5 for range g2:g6
then move onto row h2:h6 and start with 2 and place i and the bottom

so it should look like this

Column G Column h Column i
1 2 3
2 3 4
3 4 5
4 5 1
5 1 2

which then i can create a bigger range from G to P


can you help, i just can't work it out i've got 1 to 5 in every row but
its
not what i want




All times are GMT +1. The time now is 05:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com