View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
joel[_315_] joel[_315_] is offline
external usenet poster
 
Posts: 1
Default Arguments within loop


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