Loop

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
 
R

RB Smissaert

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
 
N

Neil

Thanks RB & Joel!

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

thanks again!

Neil
 
R

RB Smissaert

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
 

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

Top