• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

How to derive multiple corresponding entries for a string

ThrottleWorks

Excel Ninja
Hi,

Please check the attached file for problem details. Can anyone help me in this please.
 

Attachments

  • Chandoo.xlsm
    9 KB · Views: 6
Hi:

Can't you use a pivot to achieve this? Anyways I have constructed a formula using pivot as helper range, if you are particular about the format in which you want the results.

Thanks
 

Attachments

  • Chandoo.xlsm
    12.8 KB · Views: 1
Hi !

Pivot is often the Way …

Anyway, try this :​
Code:
Sub Demo1()
    Dim Rg As Range
    Application.ScreenUpdating = False
                            L& = 3
With Sheet1
             .Cells(4).CurrentRegion.Clear
    Set Rg = .Cells(1).CurrentRegion.Rows
        Rg("2:3").Copy .[D2]

    For R& = 4 To Rg.Count
        If Rg.Cells(R, 1).Value <> Rg.Cells(R - 1, 1).Value Then
            L = L + 1:    Rg(R).Copy .Cells(L, 4)
  
        ElseIf Rg.Cells(R, 2).Value <> Rg.Cells(R - 1, 2).Value Then
            C& = .Cells(L, 4).End(xlToRight).Column + 1
               Rg.Cells(R, 2).Copy .Cells(L, C)
              If .Cells(2, C).Value = "" Then .Cells(2, C - 1).Copy .Cells(2, C)
        End If
    Next
End With
    Set Rg = Nothing
End Sub
By code, many ways to achieve that
but it depends on the real source data, the number of lines, …
 
Back
Top