Hi,
              Try this code

Range("A1").select

while Activecell.value <> ""
if len(Activecell.value) >3 then
   Activecell.offset(0,1).value = Activecell.value
else
  Activecell.offset(0,1).value =  0 & Activecell.value

end if
Activecell.offset(1,0).select
wend

Regards
Bala

On May 27, 6:01 am, Rick <rjmag...@gmail.com> wrote:
> I have code below to put a list of ID's from this:
> 123
> 122
> 121
> 3532
>
> to this:  ('0123','0122','0121','03532')
>
> However, I only want to put a zero in front of the ID if it is 3
> characters in lenght. Desired output would be
> ('0123','0122','0121','3532'). Any help would be appreciated.
>
> thanks,
>
> Public Sub Create_LIST()
>
> Range("A1").Select
> Range(Selection, Selection.End(xlDown)).Select
>
> For Each vCell In Selection.Cells
>
> If vSQL = "" Then
> vSQL = vCell
> Else
> vSQL = vSQL & "','0" & vCell
> End If
>
> Next vCell
>
> Range("B1").Select
> Range("B1").Value = "('0" & vSQL & "')"
> Selection.Copy
>
> End Sub

--~--~---------~--~----~------------~-------~--~----~
-------------------------------------------------------------------------------------
Some important links for excel users:
1. Excel and VBA Tutorials(Video and Text), Free add-ins downloads at 
http://www.excelitems.com
2. Excel tutorials at http://www.excel-macros.blogspot.com
3. Learn VBA Macros at http://www.vbamacros.blogspot.com
4. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 

To post to this group, send email to excel-macros@googlegroups.com
If you find any spam message in the group, please send an email to:
Ayush Jain  @ jainayus...@gmail.com or
Ashish Jain @ 26may.1...@gmail.com
-------------------------------------------------------------------------------------
-~----------~----~----~----~------~----~------~--~---

Reply via email to