Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
returning back to loop check condition without completing the loop | Excel Programming | |||
Loop to Filter, Name Sheets. If Blank, Exit Loop | Excel Programming | |||
Naming Worksheets - Loop within a loop issue | Excel Programming | |||
Advancing outer Loop Based on criteria of inner loop | Excel Programming | |||
Problem adding charts using Do-Loop Until loop | Excel Programming |