LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default Union, intersection, join

Hi
Maybe something like
Sub Macro1()
Dim rng As Range
Sheets("S1").Select
Range("A:A").Copy
Sheets("S3").Select
Range("A1").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Offset(0, 1) = "S1"
Selection.End(xlDown).Offset(1, 0).Select
Sheets("S2").Select
Range("A1").Select
Range(Selection, Selection.End(xlDown)).Name = "MYR"
For Each CELL In Range("MYR")
Sheets("S1").Select
Set rng = Cells.Find(What:=CELL, After:=ActiveCell, LookIn:=xlFormulas,
LookAt:= _
xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext,
MatchCase:=False)
If Not rng Is Nothing Then
Sheets("S4").Select
ActiveCell = CELL.Value
ActiveCell.Offset(1, 0).Select
Else
Sheets("S3").Select
ActiveCell = CELL.Value
ActiveCell.Offset(0, 1) = "S2"
ActiveCell.Offset(1, 0).Select
End If
Next CELL

End Sub
This copies everthing from s1 to s3 then looks at s2 anf if can not be found
in s1 copies to s3 else to s4

Tina

"swchee" wrote:


Dear macro experts:

Hi, I have a workbook with 2 worksheets, S1 and S2.
The content in S1 is

A
B
C
100

and content in S2 is

X
Y
Z
A
B

(1) How do merge these 2 worksheets into a new worksheet in the same
workbook and display the unique value of S1 and S2, (Union)
expected output, Let say S3 :

100
A
B
C
X
Y
Z

(2) To find the intersection......
expected output, Let say S4 :

A
B


(3) to find the join of two worksheets and indicate the source...
expected output, let say S5:

100 | S1
A
B
C | S1
X | S2
Y |S2
Z | S2


* Question 3 will have 2 columns, the first column indicate the value
and second column indicate the source file. Since A and B found in both
S1 and S2, so just leave blank.

Thank you very much for your kind help. Thanks


--
swchee
------------------------------------------------------------------------
swchee's Profile: http://www.excelforum.com/member.php...o&userid=24279
View this thread: http://www.excelforum.com/showthread...hreadid=382671


 
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
Union or Join Sheets Jeff C Excel Discussion (Misc queries) 2 January 6th 09 06:16 PM
set operations: union, intersection, etc. and alignment T Magritte Excel Discussion (Misc queries) 4 September 4th 08 06:14 PM
Join tables like inner join in Access ryanp Excel Discussion (Misc queries) 2 July 18th 08 03:35 PM
Intersection, union and difference paulinoluciano Excel Worksheet Functions 2 May 3rd 06 10:51 AM
Help w/ Union Queries Jenn Excel Discussion (Misc queries) 1 January 12th 05 01:07 AM


All times are GMT +1. The time now is 03:29 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"