Loop

  • Thread starter Thread starter Neil
  • Start date Start date
N

Neil

Hi,

Is there some way to put a number sequence in the following pattern
into a sheet..
A B C D E F
Row 1 a
Row 2 a b
Row 3 a b c
Row 4 a b c d
Row 5 a b c d e
Row 6 a b c d e f


Thanks

Neil
 
Sub FillUp(lMax As Long)

Dim r As Long
Dim c As Long

For r = 1 To lMax
For c = 1 To r
Cells(r, c) = Chr(96 + c)
Next c
Next r

End Sub


Sub test()

FillUp 6

End Sub


RBS
 
Thanks RB & Joel!

I'm trying to understand how this loop works..could you explain
please?

thanks again!

Neil
 
Look in the help at For Next loops.
There is an outer loop (r counter), looping through rows and an
inner loop (c counter), looping through columns.
You could add a Msgbox before the cells line:
Msgbox "now doing row " & r & vbcrlf & "column " & c
to make it clearer what is going on.
A basic book about VB(A) would help.

RBS


Thanks RB & Joel!

I'm trying to understand how this loop works..could you explain
please?

thanks again!

Neil
 
Back
Top