View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.programming
Clif McIrvin[_3_] Clif McIrvin[_3_] is offline
external usenet poster
 
Posts: 203
Default Spliting digits up to fit paper form

I was wondering if you were going to weigh in ... I like it!

"Rick Rothstein" wrote in message
...
Why so many lines of code? <g

Sub ParseAmountsRick()
Dim Cell As Range
For Each Cell In Selection
Cell.Offset(, 1).Resize(, 9) = Split(Format(Replace(Replace( _
Cell.Text, ".", ""), ",", ""), "@_@_@_@_@_@_@_@_@"), "_")
Next
End Sub

Rick Rothstein (MVP - Excel)


Here 's the array approach I mentioned. It does not enter leading
zeros.

(Same assumptions apply as for previous post)

Sub ParseAmounts5()
Dim sTemp As String, vTemp(1 To 9) As Variant
Dim c As Variant, i As Integer, iLen As Integer
For Each c In Selection
sTemp = Replace(Format(c.Value, "0000000.00"), ".", "")
iLen = 1 '//initialize counter
For i = 1 To Len(sTemp)
If Mid$(sTemp, i, 1) 0 Then Exit For
iLen = iLen + 1
Next 'i
For i = iLen To UBound(vTemp)
vTemp(i) = Mid$(sTemp, i, 1)
Next 'i
c.Offset(, 1).Resize(1, UBound(vTemp)) = vTemp
Erase vTemp
Next 'c
End Sub




--
Clif McIrvin

(clare reads his mail with moe, nomail feeds the bit bucket :-)