View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Ryan H Ryan H is offline
external usenet poster
 
Posts: 489
Default Arguments within loop

You can try the Select Case statement too.

Select Case True
Case counter < 10
Cells(conte + 1, 2) = "VBLT-0000" & counter & Chr(Toto)

Case counter = 10 And counter < 100
Cells(conte + 1, 2) = "VBLT-000" & counter & Chr(Toto)

Case counter = 100 And counter < 1000
Cells(conte + 1, 2) = "VBLT-00" & counter & Chr(Toto)

Case counter = 1000
Cells(conte + 1, 2) = "VBLT-0" & counter & Chr(Toto)
End Select

Let me know if this helps! If so, click "YES" below.
--
Cheers,
Ryan


"Marc Gendron" wrote:

Hi gurus,

I have a small bit of code that works fine, but when I try to "improve" it,
I get a "Wend without While" message.

Here's my inner loop:

While nextCell.Value = myCell.Value

Cells(conte + 1, 2) = "VBLT-0000" & counter & Chr(Toto)

Toto = Toto + 1
conte = conte + 1
Set myCell = Cells(conte, 3)
Set nextCell = Cells(conte + 1, 3)
Wend


Simple enough !
If I try to make it fancy and replace the line that begins with Cells with
this IF block below, then I get an error message (Wend without While)
What gives ?

If counter < 10 Then
Cells(conte + 1, 2) = "VBLT-0000" & counter & Chr(Toto)
If counter = 10 And counter < 100 Then
Cells(conte + 1, 2) = "VBLT-000" & counter & Chr(Toto)
If counter = 100 And counter < 1000 Then
Cells(conte + 1, 2) = "VBLT-00" & counter & Chr(Toto)
If counter = 1000 Then
Cells(conte + 1, 2) = "VBLT-0" & counter & Chr(Toto)
End If

Thanks in advance!
Marc