Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default 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


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it a way to get a unique list from multiple columns? PL New Users to Excel 2 June 23rd 07 10:50 AM
How can I average data from a repeating list into a unique list? Duke Carey Excel Worksheet Functions 0 March 3rd 06 06:38 PM
Compare multiple column of data and list out common and unique component in adj columns kuansheng Excel Worksheet Functions 15 February 1st 06 10:49 PM
Data Validation using List (But needs unique list in drop down lis Tan New Users to Excel 1 July 8th 05 03:32 PM
Making list with unique columns Adam Excel Worksheet Functions 7 March 11th 05 09:21 AM


All times are GMT +1. The time now is 08:12 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"