How to create multiple rows combining data sets
I have three tables and i need an out put which has data from two tables, i would like to create the same using macro.
Table A
A
B
C
D
Table B
Apple
Orange
Pears
Table C
Americas
Asia
Europe
The Output i need is
A Apple Americas
A Apple Asia
A Apple Europe
A Orange Americas
A Orange Asia
A Orange Europe
So i guess for each letter from Table A, there would be 12 additional rows created. The above is the sample data and I have around 5000 rows in Table A.
This will do it, just modify as appropriate
Sub Umesh()
Application.ScreenUpdating = False
Dim i As Integer
Dim c As Range
Dim d As Range
Dim e As Range
i = 1
For Each c In Worksheets("Sheet1").Range("A:A")
If c <> "" Then
For Each d In Worksheets("Sheet2").Range("A:A")
If d <> "" Then
For Each e In Worksheets("sheet3").Range("A:A")
If e <> "" Then
Worksheets("sheet4").Cells(i, 1) = c.Value
Worksheets("sheet4").Cells(i, 2) = d.Value
Worksheets("Sheet4").Cells(i, 3) = e.Value
i = i + 1
End If
Next e
End If
Next d
End If
Next c
Application.ScreenUpdating = True
End Sub