generate list from 2 separate sheet

Yvan L

New Member
Joined
May 29, 2018
Messages
5
Hi all wondering if someone could help me out. What im trying to do seem simple but i was unable to figure it out with either a formula or a macro any help would be greatly appreciated
here's my problem
I would like to have value from Sheet(1) column C and value from Sheet(2) Column E generate a list on Sheet(3) A1 to be used for a dropdown list.

example
result wanted
|Sheet 1 Col "C"| |Sheet (2) Col "E"| |Sheet (3) Col "A"|
| | | | | |
| Jack | | Daniel | | Jack |
| Mickey | | Mouse | | Mickey |
| | | | | Daniel |
| | | | | Mouse |

Or if there's a better way maybe with a formula in the Data validation?

Thanks
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
That didn't work here's what it's supposed to look like.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Sheet (1) Col "C"[/TD]
[TD]Sheet (2) Col "E"[/TD]
[TD]Sheet (3) Col "A"[/TD]
[/TR]
[TR]
[TD]Jack[/TD]
[TD]Daniel[/TD]
[TD]Jack[/TD]
[/TR]
[TR]
[TD]Mickey[/TD]
[TD]Mouse[/TD]
[TD]Mickey[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]Daniel[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]Mouse[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Hi & welcome to the board.
How about
Code:
Sub CopyCompare()
   Dim Cl As Range
   Dim Ws1 As Worksheet
   Dim Ws2 As Worksheet

Application.ScreenUpdating = False
   Set Ws1 = Sheets("[COLOR=#ff0000]Sheet1[/COLOR]")
   Set Ws2 = Sheets("[COLOR=#ff0000]Sheet2[/COLOR]")
   With CreateObject("scripting.dictionary")
      For Each Cl In Ws1.Range("C2", Ws1.Range("C" & Rows.Count).End(xlUp))
         If Not .Exists(Cl.Value) Then .Add Cl.Value, Nothing
      Next Cl
      For Each Cl In Ws2.Range("E2", Ws2.Range("E" & Rows.Count).End(xlUp))
         If Not .Exists(Cl.Value) Then .Add Cl.Value, Nothing
      Next Cl
   Sheets("[COLOR=#ff0000]Sheet3[/COLOR]").Range("A1").Resize(.Count).Value = Application.Transpose(.keys)
   End With
End Sub
Change sheet names to suit
 
Upvote 0
One more question if I may.
Is there a way I could get the code to also make it with unique value and sorted ascending
 
Upvote 0
How about
Code:
Sub CopyCompare()
   Dim Cl As Range
   Dim Ws1 As Worksheet
   Dim Ws2 As Worksheet
   Dim Lst As Object, Ky As Variant

Application.ScreenUpdating = False
   Set Lst = CreateObject("System.Collections.ArrayList")
   Set Ws1 = Sheets("pcode")
   Set Ws2 = Sheets("Sheet2")
   
   With CreateObject("scripting.dictionary")
      For Each Cl In Ws1.Range("C2", Ws1.Range("C" & Rows.Count).End(xlUp))
         If Not .Exists(Cl.Value) Then .Add Cl.Value, Nothing
      Next Cl
      For Each Cl In Ws2.Range("E2", Ws2.Range("E" & Rows.Count).End(xlUp))
         If Not .Exists(Cl.Value) Then .Add Cl.Value, Nothing
      Next Cl
      For Each Ky In .keys
         Lst.Add Ky
      Next Ky
      Lst.Sort
   Sheets("Sheet3").Range("A1").Resize(.Count).Value = Application.Transpose(Lst.toarray)
   End With
End Sub
 
Upvote 0
Glad to help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,996
Members
452,373
Latest member
TimReeks

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