We help IT Professionals succeed at work.
Get Started

Text to row

jaffan72
jaffan72 asked
on
219 Views
Last Modified: 2012-05-09
Hello All,
I posted this question before and I got the answer for it, but after further analysis, i found out an error in the result. so please look at the attached file to understand my request. you can also find below the code i have been useing.
Sub MakeTheList()
    
    Dim arr As Variant
    Dim r As Long, c As Long
    Dim DestR As Long
    Dim Countries As Variant
    
    arr = ActiveSheet.UsedRange.Value
    Worksheets.Add
    [a1:e1] = Array("Country Code", "date", "value", "points", "City Code")
    
    DestR = 1
    
    For r = 2 To UBound(arr, 1)
    
    If arr(r, 5) = "" Then
            Cells(DestR, 1) = arr(r, 1)
            Cells(DestR, 2) = arr(r, 2)
            Cells(DestR, 3) = arr(r, 3)
            Cells(DestR, 4) = arr(r, 4)
            Cells(DestR, 5) = arr(r, 5)
           End If
        Countries = Split(arr(r, 5), ",")
        For c = 0 To UBound(Countries)
            DestR = DestR + 1
            Cells(DestR, 1) = arr(r, 1)
            Cells(DestR, 2) = arr(r, 2)
            Cells(DestR, 3) = arr(r, 3)
            Cells(DestR, 4) = arr(r, 4)
            Cells(DestR, 5) = Trim(Countries(c))
           
        Next
    Next
    

End Sub

Open in new window

Problem.xlsx
Comment
Watch Question
CERTIFIED EXPERT
Top Expert 2010
Commented:
This problem has been solved!
Unlock 1 Answer and 7 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE