Have to repeat list

Closed
kashif.aali Posts 1 Registration date Tuesday May 16, 2017 Status Member Last seen May 16, 2017 - May 16, 2017 at 02:17 AM
TrowaD Posts 2921 Registration date Sunday September 12, 2010 Status Moderator Last seen December 27, 2022 - May 16, 2017 at 11:12 AM
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 September 12, 2010 Status Moderator Last seen December 27, 2022 555
May 16, 2017 at 11:12 AM
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
0