Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

split row

Status
Not open for further replies.

ram567

Programmer
Dec 28, 2007
123
US
hI!
I am tryin to do colum c ( 1 to nth row)
split and put it in column M
coudl you check it what is wrong in this one.
thanks in advance
Sub test()
Dim strTest As String
Dim arrTest As Variant
Dim strColC As String, strColM As String, RW as integer

strTest = [C1]
arrTest = Split(strTest, ",")
For RW = 1 to 46
For i = LBound(arrTest) To UBound(arrTest)
If Len(arrTest(i)) <= 5 Then
strColC = strColC & "," & arrTest(i)
Else
strColM = strColM & "," & arrTest(i)
End If
Next i
RW = RW +1
strColC = Right(strColC, Len(strColC) - 1)
strColM = Right(strColM, Len(strColM) - 1)
Next J
MsgBox strColC & vbCrLf & strColM

End Sub

 



Code:
    Dim i As Integer
    Dim arrTest As Variant
    Dim strColC As String, strColM As String, RW As Integer
    
    For RW = 1 To 46
'this must be within the loop
        arrTest = Split(Cells(RW, "C").Value, ",")

        For i = LBound(arrTest) To UBound(arrTest)
            If Len(arrTest(i)) <= 5 Then
                strColC = strColC & "," & arrTest(i)
            Else
                strColM = strColM & "," & arrTest(i)
            End If
        Next i
    Next RW
'this is probably outside both loops - final cleanup
    strColC = Right(strColC, Len(strColC) - 1)
    strColM = Right(strColM, Len(strColM) - 1)
    
    MsgBox strColC & vbCrLf & strColM

Skip,

[glasses]Did you hear what happened when the OO programmer lost his library?...
He's now living in OBJECT poverty![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top