K
Ken
As part of a larger macro we have a column (Column A) formatted as numeric
that we now want to treat as text. We want to add two leading zeros to those
cells that are one digit numbers and add one leading zero to those cells that
are two digit numbers.
How do we need to change this code to do what we want?
TIA.
'Convert CP field to text format.
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), FieldInfo:=Array(1, 2)
'Insert leading zeros into CP number
For ILoop = 1 To NumRowsFMS
If Len(Cells(ILoop, 1)) = 1 Then
Cells(ILoop, 1) = "00" & Cells(ILoop, 1)
End If
If Len(Cells(ILoop, 1)) = 2 Then
Cells(ILoop, 1) = "0" & Cells(ILoop, 1)
End If
Next ILoop
that we now want to treat as text. We want to add two leading zeros to those
cells that are one digit numbers and add one leading zero to those cells that
are two digit numbers.
How do we need to change this code to do what we want?
TIA.
'Convert CP field to text format.
Columns("A:A").Select
Selection.TextToColumns Destination:=Range("A1"), FieldInfo:=Array(1, 2)
'Insert leading zeros into CP number
For ILoop = 1 To NumRowsFMS
If Len(Cells(ILoop, 1)) = 1 Then
Cells(ILoop, 1) = "00" & Cells(ILoop, 1)
End If
If Len(Cells(ILoop, 1)) = 2 Then
Cells(ILoop, 1) = "0" & Cells(ILoop, 1)
End If
Next ILoop