Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Match excel spread sheet with macro

I have one excel spread sheet with sheet1 and sheet2, they both only have
columnA,

on sheet1 as following:




on sheet2 as following:





so sheet2 has
, sheet1 does not have this.
so how to write the macro match this two sheet1 and sheet2 columnA and have
result
show up on sheet1

thanks
Lillian
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default Match excel spread sheet with macro

hi
this worked on your sample data. paste it in a standard module. back up your
data before runing it.
Sub twolists()
Dim r As Range
Dim rd As Range
Dim ro As Range
Dim rod As Range
Dim des As Range
Sheets("Sheet1").Activate
Columns("A:A").Sort Key1:=Range("A1"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Sheets("Sheet2").Activate
Columns("A:A").Sort Key1:=Range("A1"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Sheets("Sheet1").Activate
Set r = Sheets("sheet1").Range("A1")
Set ro = Sheets("sheet2").Range("A1")

Do While Not IsEmpty(ro)
Set rd = r.Offset(1, 0)
Set des = Sheets("sheet1").Range("A1"). _
End(xlDown).Offset(1, 0)
Set rod = ro.Offset(1, 0)
If r.Value < ro.Value Then
des.Value = ro.Value
Set ro = rod
Else
Set r = rd
Set ro = rod
End If
Loop
MsgBox ("Done!")
End Sub

regards
FSt1


"Lillian Lian" wrote:

I have one excel spread sheet with sheet1 and sheet2, they both only have
columnA,

on sheet1 as following:




on sheet2 as following:





so sheet2 has
, sheet1 does not have this.
so how to write the macro match this two sheet1 and sheet2 columnA and have
result
show up on sheet1

thanks
Lillian

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Match excel spread sheet with macro

I run through this program is work, but the record is not correct,
on the sheet1...422 rows
on the sheet2...446 rows.
so combined two together I have 866 rows, but this alreay counting duplicate
record, I know the real counts about 500 records or more, but not 866 records.
how do you do that?

Thanks.

Lillian

"FSt1" wrote:

hi
this worked on your sample data. paste it in a standard module. back up your
data before runing it.
Sub twolists()
Dim r As Range
Dim rd As Range
Dim ro As Range
Dim rod As Range
Dim des As Range
Sheets("Sheet1").Activate
Columns("A:A").Sort Key1:=Range("A1"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Sheets("Sheet2").Activate
Columns("A:A").Sort Key1:=Range("A1"), _
Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Sheets("Sheet1").Activate
Set r = Sheets("sheet1").Range("A1")
Set ro = Sheets("sheet2").Range("A1")

Do While Not IsEmpty(ro)
Set rd = r.Offset(1, 0)
Set des = Sheets("sheet1").Range("A1"). _
End(xlDown).Offset(1, 0)
Set rod = ro.Offset(1, 0)
If r.Value < ro.Value Then
des.Value = ro.Value
Set ro = rod
Else
Set r = rd
Set ro = rod
End If
Loop
MsgBox ("Done!")
End Sub

regards
FSt1


"Lillian Lian" wrote:

I have one excel spread sheet with sheet1 and sheet2, they both only have
columnA,

on sheet1 as following:




on sheet2 as following:





so sheet2 has
, sheet1 does not have this.
so how to write the macro match this two sheet1 and sheet2 columnA and have
result
show up on sheet1

thanks
Lillian

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
Match two excel spread sheet using Macro Lillian Lian Excel Programming 2 September 25th 07 03:46 PM
match two excel spread sheet using macro Lillian Lian Excel Programming 11 September 19th 07 03:17 PM
Compare two excel spread sheet with macro Lillian Lian Excel Programming 5 September 11th 07 09:04 PM
Created another spread sheet if SSN is not match Lillian Excel Programming 3 August 2nd 05 08:51 PM
can I clean old excel data format with macro on funny spread sheet Todd F.[_2_] Excel Programming 0 July 22nd 05 09:15 PM


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