need help with creating macro for unique list from 2 rows

bishop7262

Board Regular
Joined
Jan 9, 2010
Messages
87
I have two columns of names that I need to have a unique list extracted into another row. Is there any way that a macro can be created to pick from 2 columns and placed in another. Here is an example of a macro that I found that lets me create a unique list from one column and gives me the option of putting that list into any column that I choose.

Sub Button18_Click()
Dim rListPaste As Range
Dim iReply As Integer

On Error Resume Next

Set rListPaste = Application.InputBox _
(Prompt:="Please select the destination cell", Type:=8)

If rListPaste Is Nothing Then
iReply = MsgBox("No range nominated," _
& " terminate", vbYesNo + vbQuestion)
If iReply = vbYes Then Exit Sub
End If

'May need to specify [NameofSheet].Range, e.g, Sheet1.Range
Range("A6", Range("A65536").End(xlUp)).AdvancedFilter _
Action:=xlFilterCopy, CopyToRange:=rListPaste.Cells(1, 1), Unique:=True
End Sub
 

Some videos you may like

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,732
Office Version
365
Platform
Windows
Why not just combine the 2 columns into one and use the code you already have?
 

bishop7262

Board Regular
Joined
Jan 9, 2010
Messages
87
great question. I am trying to make a user friendly excel sheet. I will have many people using this that are not comfortable with using pc much less messing around with excel. So was just wondering if there was a more user friendly way to do this.
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,732
Office Version
365
Platform
Windows
I did mean use code to combine the 2 columns, is that any use?

That should be pretty straightforward unless there's more to what you want to do.

For example, do you want the user to deide where the unique list ends up?
 

bishop7262

Board Regular
Joined
Jan 9, 2010
Messages
87
Sorry misunderstood. I just do not know how to change the code to do what I need. If the code could combine and create a unique list and place it in another column that would be what I am looking for. I would like the unique list to go into a particular column, example c7
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,158
Messages
5,509,500
Members
408,738
Latest member
mkarhoff

This Week's Hot Topics

  • Turn fraction around
    Hello I need to turn a fraction around, for example I have 1/3 but I need to present as 3/1
  • TIme Clock record reformatting to ???
    Hello All, I'd like some help formatting this (Tbl-A)(Loaded via Power Query) [ATTACH type="full" width="511px" alt="PQdata.png"]22252[/ATTACH]...
  • TextBox Match
    hi, I am having a few issues with my code below, what I need it to do is when they enter a value in textbox8 (QTY) either 1,2 or 3 the 3 textboxes...
  • Using Large function based on Multiple Criteria
    Hello, I can't seem to get a Large formula to work based on two criteria's. I can easily get a oldest value based one value, but I'm struggling...
  • Can you check my code please
    Hi, Im going round in circles with a Compil Error End With Without With Here is the code [CODE=rich] Private Sub...
  • Combining 2 pivot tables into 1 chart
    Hello everyone, My question sounds simple but I do not know the answer. I have 2 pivot tables and 2 charts that go with this. However I want to...
Top