View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
cliee cliee is offline
external usenet poster
 
Posts: 2
Default for next loop problems

Hi I am a excel programming beginner, so my question may be stupid

1. how to jump out from a for next loop without error?

eg

For LR = 5 To 25 Step 4
For LC = 1 To 5 Step 1
If ActiveSheet.cells(LR,LC).Value < True Then
Worksheets("Label-s").cells(LR, LC).Value = "abcde"
Worksheets("Label-s").cells(LR+1,LC).Value = "Art no. " & art & " " & des
Worksheets("Label-s").cells(LR+2,LC).Value = con & " " & hen & " " & w
GoTo 178
End If
Next LC
Next LR

I use (goto 178) to go to line 178 is this the right way?
(line 178 is the end of this macro)
-------------------------------------------------


2. I want the follow order for the for next loop

5,9,13,17,21,25
so I use this
For LR = 5 To 25 Step 4

I want 1,3,5
so I use
For LC = 1 To 5 Step 1

the result is that the variable fill in cells I do not wanted such as A8
A13, and b6 .......

the result what I want ( the cells which is fill in something) are like this....

a5 c5 e5
a6 c6 e6
a7 c7 e7

a9 c9 e9
a10 c10 e10
a11 c11 e11

............



thanks for help