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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> 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
>