Have to repeat list

Closed
kashif.aali Posts 1 Registration date Tuesday 16 May 2017 Status Member Last seen 16 May 2017 - 16 May 2017 à 02:17
TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 - 16 May 2017 à 11:12
Dear all Please help out
have to repeat two list in one list.

Query:
List A List B
A 1
B 2
C 3
D


Results
List C
A 1
A 2
A 3
B 1
B 2
B 3

Thanks in advance

1 response

TrowaD Posts 2921 Registration date Sunday 12 September 2010 Status Contributor Last seen 27 December 2022 555
16 May 2017 à 11:12
Hi Kashif.aali,

Give the following code a try:
Sub RunMe()
Dim x, y, z As Integer

x = 1
y = 1
z = 1

Do
    Cells(x, "C").Value = Cells(y, "A") & " " & Cells(z, "B")
    x = x + 1
    z = z + 1
    
    If z > 3 Then
        y = y + 1
        z = 1
    End If
    
Loop Until IsEmpty(Cells(y, "A"))
End Sub


Best regards,
Trowa