#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Loop

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Loop


Sub writeLeters()

Letter_A = Asc("a")
For i = 1 To 260
LetterNumber = (i - 1) Mod 26
For j = 1 To (LetterNumber + 1)
NewLetter = Chr(Letter_A + (j - 1))
Cells(i, j) = NewLetter
Next j
Next i

End Sub


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=170229

Microsoft Office Help

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Loop

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


"Neil" wrote in message
...
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


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Loop

Thanks RB & Joel!

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

thanks again!

Neil
On Jan 15, 9:09*am, "RB Smissaert"
wrote:
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

"Neil" wrote in message

...



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- Hide quoted text -


- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Loop

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


"Neil" wrote in message
...
Thanks RB & Joel!

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

thanks again!

Neil
On Jan 15, 9:09 am, "RB Smissaert"
wrote:
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

"Neil" wrote in message

...



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- Hide quoted text -


- Show quoted text -




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Loop


Each character has a ASCII code asociated with each character. The
lower case letters a-z start at character 96

Characternumber = asc("a") will equal 96


The letter b is 97 which is asc("a") + 1
The letter c is 98 which is asc("a") + 2


to convert a number back to the letter use the method Chr()

So MyLetterA = chr(96) which is lowercase "a".


the letter b equals chr(asc("a") + 1)
the letter c equals chr(asc("a") + 2)
the letter d equals chr(asc("a") + 3)


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=170229

Microsoft Office Help

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Loop

Except that "a" is Chr(97):
MsgBox Asc("a") , , Chr(97)

RBS


"joel" wrote in message
...

Each character has a ASCII code asociated with each character. The
lower case letters a-z start at character 96

Characternumber = asc("a") will equal 96


The letter b is 97 which is asc("a") + 1
The letter c is 98 which is asc("a") + 2


to convert a number back to the letter use the method Chr()

So MyLetterA = chr(96) which is lowercase "a".


the letter b equals chr(asc("a") + 1)
the letter c equals chr(asc("a") + 2)
the letter d equals chr(asc("a") + 3)


--
joel
------------------------------------------------------------------------
joel's Profile: 229
View this thread:
http://www.thecodecage.com/forumz/sh...d.php?t=170229

Microsoft Office Help


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
returning back to loop check condition without completing the loop ashish128 Excel Programming 13 April 3rd 08 12:53 PM
Loop to Filter, Name Sheets. If Blank, Exit Loop ryguy7272 Excel Programming 3 February 5th 08 03:41 PM
Naming Worksheets - Loop within a loop issue klysell Excel Programming 5 March 29th 07 05:48 AM
Advancing outer Loop Based on criteria of inner loop ExcelMonkey Excel Programming 1 August 15th 05 05:23 PM
Problem adding charts using Do-Loop Until loop Chris Bromley[_2_] Excel Programming 2 May 23rd 05 01:31 PM


All times are GMT +1. The time now is 06:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"