View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Marc Gendron[_2_] Marc Gendron[_2_] is offline
external usenet poster
 
Posts: 16
Default Arguments within loop

I knew the word "Guru" what right...not only did you solve my problem, but
you taught me too....thanks for the time guys !

"Rick Rothstein" wrote:

One more way (another one-liner like your last example) that you missed...

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

--
Rick (MVP - Excel)


"joel" wrote in message
...

You need an End IF for each IF. Here are 3 methods you can use


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


or

select Case Counter
Case is < 10
Cells(conte + 1, 2) = "VBLT-0000" & counter & Chr(Toto)
Case is < 100
Cells(conte + 1, 2) = "VBLT-000" & counter & Chr(Toto)
Case is < 1000
Cells(conte + 1, 2) = "VBLT-00" & counter & Chr(Toto)
Case Else
Cells(conte + 1, 2) = "VBLT-0" & counter & Chr(Toto)
end Select


or
Cells(conte + 1, 2) = "VBLT-" & String(5 - Len(Counter), "0") &
_
counter & Chr(Toto)


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

Microsoft Office Help


.