simple loop needed please

A

Alan

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
 
P

Per Jessen

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top