How could I do this...thanks in advance

mrcrappy

New Member
Joined
Apr 14, 2011
Messages
7
Hi Everyone,

Wondering if anyone could help.

I have 2 sheets - Sheet A and B

Sheet A has a single column list of numbers 1,2,3.....

Sheet B has a single column of letters a,b,c,d,e


Is there a way i can merge the 2 sheets so i end up with a new sheet or the information in Sheet A to look like:

column 1 column 2
1 a
1 b
1 c
1 d
1 e
2 a
2 b
2 c
2 d
2 e


Hope you catch the drift.

Thanks again!!
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Thanks VOG, but perhaps I wasn't too clear.

Basically I have a list in sheet 1 of unique values.
In sheet 2 I have a list of tasks eg. task 1, task 2, task 3 etc.

I wanted to merge the 2 so i ended up with each unique value on a seperate row with a corresponding task.

eg.

001 task1
001 task2
001 task3
002 task1
002 task2
002 task3
003 task1
003 task2
003 task3
etc
 
Upvote 0
Try this macro

Code:
Sub MakeList()
Dim ws1 As Worksheet, ws2 As Worksheet, ws3 As Worksheet
Dim LR1 As Long, LR2 As Long
Dim i As Long, j As Long, k As Long
Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
Set ws3 = Sheets.Add
LR1 = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
LR2 = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LR1
    For j = 1 To LR2
        k = k + 1
        ws3.Cells(k, 1).Value = ws1.Cells(i, 1).Value
        ws3.Cells(k, 2).Value = ws2.Cells(j, 1).Value
    Next j
Next i
End Sub
 
Upvote 0
VoG you legend!!!! thank you so much.

However, it seems to be creating 2 extraneous rows after each group of tasks.
Wish I understood the macro more but any chance of highlighting where the issue may be?


Thanks for your time.
 
Upvote 0
I think you must have some extraneous spaces in apparently empty cells on the input sheets. Try selecting the first few blank rows at the end of your input sheets and pressing the Delete key.
 
Upvote 0
In response to your PM, to include columns A and B from Sheet1 try

Code:
Sub MakeList()
Dim ws1 As Worksheet, ws2 As Worksheet, ws3 As Worksheet
Dim LR1 As Long, LR2 As Long
Dim i As Long, j As Long, k As Long
Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
Set ws3 = Sheets.Add
LR1 = Sheets("Sheet1").Range("A" & Rows.Count).End(xlUp).Row
LR2 = Sheets("Sheet2").Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To LR1
    For j = 1 To LR2
        k = k + 1
        ws3.Cells(k, 1).Value = ws1.Cells(i, 1).Value
        ws3.Cells(k, 2).Value = ws1.Cells(i, 2).Value
        ws3.Cells(k, 3).Value = ws2.Cells(j, 1).Value
    Next j
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,843
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top