You could keep the values numeric and format the cell with a custom format: 00
Or you could format the cells as Text and plop them in as text.
Option Explicit
Sub testme01()
Dim myArr As Variant
Dim myCell As Range
myArr = Array(1, 2, 12, 25)
Set myCell = ActiveSheet.Range("A1")
With myCell.Resize(UBound(myArr) - LBound(myArr) + 1, 1)
.NumberFormat = "00"
.Value = Application.Transpose(myArr)
End With
End Sub
or
Option Explicit
Sub testme02()
Dim myArr As Variant
Dim myCell As Range
Dim iCtr As Long
Dim myOffset As Long
myArr = Array(1, 2, 12, 25)
Set myCell = ActiveSheet.Range("A1")
With myCell.Resize(UBound(myArr) - LBound(myArr) + 1, 1)
.NumberFormat = "@" 'text
End With
myOffset = 0
For iCtr = LBound(myArr) To UBound(myArr)
myCell.Offset(myOffset, 0).Value = Format(myArr(iCtr), "00")
myOffset = myOffset + 1
Next iCtr
End Sub
jay dean wrote:
Hello -
Arr1() contains strings. When I unload them into my sheet (one index
Arr1()content per cell), I would like for all the single digits to be
padded with a zero. For example, "1" should show as "01", "5" as "05",
e.t.c.. Any help would be appreciated.
Thanks
Jay Dean
*** Sent via Developersdex http://www.developersdex.com ***
--
Dave Peterson