ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Question about a unique list in VBA by checking data inside of 2 columns (https://www.excelbanter.com/excel-discussion-misc-queries/155140-question-about-unique-list-vba-checking-data-inside-2-columns.html)

Avenarius

Question about a unique list in VBA by checking data inside of 2 columns
 
Hi all,

I have a question in terms of a unique list generation.

My list looks like:

Column A
Name1
Name2
Name3
Name1
Name1

Column B
Name4
Name2
Name3
Name1
Name1
Name2

and so on

The result I am looking for is a new spreadsheet containing:
Name1
Name2
Name3
Name4


Any ideas about how to get that ready?

Thank you in advance.

Cheers,
Avenarius


joel

Question about a unique list in VBA by checking data inside of 2 c
 
Lots of people ask for the macro

Sub mergecolumns()

Set OldSheet = ActiveSheet
With OldSheet
LastRowColA = Cells(Rows.Count, "A").End(xlUp).Row
Set ColARange = .Range(Cells(1, "A"), _
Cells(LastRowColA, "A"))

LastRowColB = Cells(Rows.Count, "B").End(xlUp).Row
Set ColBRange = .Range(Cells(1, "B"), _
Cells(LastRowColB, "B"))
End With

Worksheets.Add after:=ActiveSheet
ActiveSheet.Name = "Summary"

RowCount = 1
For Each cell In ColARange
If RowCount = 1 Then
Cells(RowCount, "A") = cell.Value
RowCount = RowCount + 1
Else
Set ColRange = Range(Cells(1, "A"), _
Cells(RowCount - 1, "A"))
Set c = ColRange.Find _
(what:=cell.Value, LookIn:=xlValues)
If c Is Nothing Then
Cells(RowCount, "A") = cell.Value
RowCount = RowCount + 1
End If

End If

Next cell

For Each cell In ColBRange
If RowCount = 1 Then
Cells(RowCount, "A") = cell.Value
RowCount = RowCount + 1
Else
Set ColRange = Range(Cells(1, "A"), _
Cells(RowCount - 1, "A"))
Set c = ColRange.Find _
(what:=cell.Value, LookIn:=xlValues)
If c Is Nothing Then
Cells(RowCount, "A") = cell.Value
RowCount = RowCount + 1
End If

End If

Next cell

End Sub


"Avenarius" wrote:

Hi all,

I have a question in terms of a unique list generation.

My list looks like:

Column A
Name1
Name2
Name3
Name1
Name1

Column B
Name4
Name2
Name3
Name1
Name1
Name2

and so on

The result I am looking for is a new spreadsheet containing:
Name1
Name2
Name3
Name4


Any ideas about how to get that ready?

Thank you in advance.

Cheers,
Avenarius




All times are GMT +1. The time now is 11:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com