Hello,

I am using group's member code to convert text (like: 1-2,3,6) to
values (1,2,3,6).
Imput is in Col A and values are writen from ColB.
I am trying to fill output array with values
but it dows not work.

Can you help me ?

Thank you

-----


Sub txt2arr()
    'Assuming that all the texts are in column-A
    'This program will fill the subsequent conlumns with the range
specified in column-A
    'for example if cell-A1 =>6, 8-10
    ' B1=6,C1=8,D1= 9, E1 = 10 and so on
    'to functions 'splitComma' and 'splitDash' will be used
    Dim ar() As String
    Dim ar2
    Dim output
    Dim i As Byte
    Dim j As Byte, k As Byte
    Dim n As Integer
    n = 1
    m = 0
    Do While (Range("A" & n) <> "")
        ar = splitComma(Range("A" & n))
        j = 2
        For i = LBound(ar) To UBound(ar)
            ar2 = splitDash(ar(i))
            For k = LBound(ar2) To UBound(ar2)
   Cells(n, j) = ar2(k)

   output(m) = ar2(k)

                m = m + 1
                j = j + 1
            Next k
        Next i
        n = n + 1
    Loop
End Sub


------
Function splitComma(t As String)
    splitComma = Split(t, ",")
End Function

-------
Function splitDash(t As String)
    Dim dSplit
    Dim i1 As Integer, i2 As Integer
    Dim j As Integer
    dSplit = Split(t, "-")
    i1 = Val(dSplit(0))
    If UBound(dSplit) = 0 Then
        splitDash = dSplit
        Exit Function
    End If
    i2 = Val(dSplit(1))
    ReDim splitVal(i2 - i1) As Integer
    For j = 0 To i2 - i1
        splitVal(j) = i1 + j
    Next j
    splitDash = splitVal
End Function

-- 
----------------------------------------------------------------------------------
Some important links for excel users:
1. Follow us on TWITTER for tips tricks and links : 
http://twitter.com/exceldailytip
2. Join our LinkedIN group @ http://www.linkedin.com/groups?gid=1871310
3. Excel tutorials at http://www.excel-macros.blogspot.com
4. Learn VBA Macros at http://www.quickvba.blogspot.com
5. Excel Tips and Tricks at http://exceldailytip.blogspot.com
 
To post to this group, send email to excel-macros@googlegroups.com

<><><><><><><><><><><><><><><><><><><><><><>
HELP US GROW !!

We reach over 7000 subscribers worldwide and receive many nice notes about the 
learning and support from the group.Let friends and co-workers know they can 
subscribe to group at http://groups.google.com/group/excel-macros/subscribe

Reply via email to