View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
jfcby[_2_] jfcby[_2_] is offline
external usenet poster
 
Posts: 121
Default Multiple For Next Statement, Excel 2000 & 2003

Hello Tom,

Thank you for your response but I need the numbers for ex:
Gen 1-3
Gen 4-6
Gen 7-9

but I'm getting:
Gen 1-2
Gen 3-4
Gen 5-6

I've changed some numbers in your code but it does not work right.

Thank you for your help,
jfcby

Tom Ogilvy wrote:
Sub aAA()
For Each BN In Range("A1:A5")
i = BN.Row
TBC = BN.Offset(0, 1)
j = 1
For v = 1 To TBC
Cells(v, i + 2).Value = _
BN & " " & j & "-" & j + 1
j = j + 2
Next
Next

End Sub

that would fill the number of cells specified in column B.


if you mean the last number in Lex 1-3 should stop at the value next to
lex, then you would do

For v = 1 To TBC/2

but the last number is always even

--
Regards,
Tom Ogilvy


"jfcby" wrote:

Hello,

In my worksheet my data looks like this:

Column A Column B
Gen 50
Ex 31
Lev 44
Num 25
Deu 36

In ColumnA and ColumnB my data goes down 66 rows. I'm tring to put my
data beginning in ColumnC after finding next blank cell then move over
to next column like this:

ColumnC ColumnD ColumnE
ColumnF
Gen 1-3 Ex 1-3 Lev 1-3
Num 1-3
Gen 4-6 Ex 4-6 Lev 4-6
Num 4-6
Gen 7-9 Ex 7-9 Lev 7-9
Num 7-9
Gen 10-12 Ex 10-12 Lev 10-12
Num 10-12
until 50 is reached until 31 is reached until 44 is reached
until 25 is reached

Here is the code I have so far but it is not working correctly.

Sub aBibleRead()

Dim BN As Range, TBC As Range
Dim v As Long, v2 As Long, v3 As Long, v4 As Long

For Each BN In Range("A1:A6")
For Each TBC In Range("B1:B6")
For v = 1 To TBC
For v2 = 3 To TBC
For v3 = v + 3 To TBC
For v4 = v2 + 3 To TBC
Range("E65536").End(xlUp).Offset(1, 0).Select
ActiveCell.Value = BN & " " & v3 & "-" & v4
Next v4
Next v3
Next v2
Next v
Next TBC
Next BN

End Sub

Thank you for your help,
jfcby