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

I have sheet1 and sheet2 both as SSN on columnA like this
sheet1
111-111-111
222-222-222
333-333-333

sheet2
111-111-111
222-222-222
444-444-444

I would like match on sheet3 showing
111-111-111
222-222-222

how do you write the macro for this?

Thanks.

Lillian


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Only matach two excel spread sheet

Sub matchsheets()

Sh1RowCount = 1
Sh3RowCount = 1
With Sheets("Sheet1")
Do While .Range("A" & Sh1RowCount) < ""
SSN = .Range("A" & Sh1RowCount)
With Sheets("Sheet2")
Set c = .Columns("A:A").Find(what:=SSN, _
LookIn:=xlValues)
If Not c Is Nothing Then
With Sheets("Sheet3")
.Range("A" & Sh3RowCount) = SSN
Sh3RowCount = Sh3RowCount + 1
End With
End If
End With
Sh1RowCount = Sh1RowCount + 1
Loop
End With
End Sub


"Lillian Lian" wrote:

I have sheet1 and sheet2 both as SSN on columnA like this
sheet1
111-111-111
222-222-222
333-333-333

sheet2
111-111-111
222-222-222
444-444-444

I would like match on sheet3 showing
111-111-111
222-222-222

how do you write the macro for this?

Thanks.

Lillian


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 26
Default Only matach two excel spread sheet

Thanks Joel, it work, your great

"Joel" wrote:

Sub matchsheets()

Sh1RowCount = 1
Sh3RowCount = 1
With Sheets("Sheet1")
Do While .Range("A" & Sh1RowCount) < ""
SSN = .Range("A" & Sh1RowCount)
With Sheets("Sheet2")
Set c = .Columns("A:A").Find(what:=SSN, _
LookIn:=xlValues)
If Not c Is Nothing Then
With Sheets("Sheet3")
.Range("A" & Sh3RowCount) = SSN
Sh3RowCount = Sh3RowCount + 1
End With
End If
End With
Sh1RowCount = Sh1RowCount + 1
Loop
End With
End Sub


"Lillian Lian" wrote:

I have sheet1 and sheet2 both as SSN on columnA like this
sheet1
111-111-111
222-222-222
333-333-333

sheet2
111-111-111
222-222-222
444-444-444

I would like match on sheet3 showing
111-111-111
222-222-222

how do you write the macro for this?

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
How to create Login & Log out Spread sheet in Excel with automated Attendance sheet marc5354 Excel Worksheet Functions 2 September 21st 10 04:22 PM
Excel spread sheet hondo Excel Discussion (Misc queries) 1 February 2nd 10 07:21 AM
How do I set up a spread sheet in excel Insurance Claim Setting up and Configuration of Excel 1 June 22nd 09 08:38 AM
how do i enter a bull call spread into the options spread sheet ? alvin smith Excel Worksheet Functions 0 November 27th 06 01:23 AM
excel spread sheet DC Charts and Charting in Excel 2 September 20th 06 12:54 AM


All times are GMT +1. The time now is 06:33 PM.

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

About Us

"It's about Microsoft Excel"