Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Create a data set from 2 different lists

I am trying to create one new list of matching data...I need to look at one
cell in one sheet and look to another sheet (column) and see if it shows up
there...if it does, I need to bring back the entire row of data for that
item...to a new sheet to start the "matching" list. Is there a way to do
something like this? I have done the vlookup thing and found the data that
matches....however, now I have to go through sort, and delete the ones that
don't match. I was wondering if someone has a shortcut. Hope I explained it
ok...Thanks.

In other words....2 sets of data, find the matching data (lets say one
cell), on a new sheet, start the list of matching data.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Create a data set from 2 different lists

Sub ABC()
Dim sh1 as Worksheet, sh2 as Worksheet
Dim sh3 as Worksheet, rng1 as Range
dim rng2 as Range, cell as Range
Dim rw as Long
set sh1 = worksheets("Sheet1")
set sh2 = worksheets("Sheet2")
worksheets.add after:=Worksheets(worksheets.count)
set sh3 = Activesheet
sh3.Name = "Matches"
with sh1
set rng1 = .Range(.cells(2,1),.cells(2,1).End(xldown))
End with

with sh2
set rng2 = .Range(.cells(2,1),.cells(2,1).End(xldown))
End with

rw = 2
for each cell in rng1
if application.Countif(rng2,cell) 0 then
sh3.cells(rw,1).Value = cell.Value
rw = rw + 1
end if
Next
End Sub

--
Regards,
Tom Ogilvy

"deeds" wrote:

I am trying to create one new list of matching data...I need to look at one
cell in one sheet and look to another sheet (column) and see if it shows up
there...if it does, I need to bring back the entire row of data for that
item...to a new sheet to start the "matching" list. Is there a way to do
something like this? I have done the vlookup thing and found the data that
matches....however, now I have to go through sort, and delete the ones that
don't match. I was wondering if someone has a shortcut. Hope I explained it
ok...Thanks.

In other words....2 sets of data, find the matching data (lets say one
cell), on a new sheet, start the list of matching data.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Create a data set from 2 different lists

Thanks Tom! That works..however, now, how do I get all of the data with that
matched figure...in other words, I need the entire row of data that is with
the matched data, so it finds the match in let's say A1, I also need to bring
back the other data in that row....any ideas? Thanks again!

"Tom Ogilvy" wrote:

Sub ABC()
Dim sh1 as Worksheet, sh2 as Worksheet
Dim sh3 as Worksheet, rng1 as Range
dim rng2 as Range, cell as Range
Dim rw as Long
set sh1 = worksheets("Sheet1")
set sh2 = worksheets("Sheet2")
worksheets.add after:=Worksheets(worksheets.count)
set sh3 = Activesheet
sh3.Name = "Matches"
with sh1
set rng1 = .Range(.cells(2,1),.cells(2,1).End(xldown))
End with

with sh2
set rng2 = .Range(.cells(2,1),.cells(2,1).End(xldown))
End with

rw = 2
for each cell in rng1
if application.Countif(rng2,cell) 0 then
sh3.cells(rw,1).Value = cell.Value
rw = rw + 1
end if
Next
End Sub

--
Regards,
Tom Ogilvy

"deeds" wrote:

I am trying to create one new list of matching data...I need to look at one
cell in one sheet and look to another sheet (column) and see if it shows up
there...if it does, I need to bring back the entire row of data for that
item...to a new sheet to start the "matching" list. Is there a way to do
something like this? I have done the vlookup thing and found the data that
matches....however, now I have to go through sort, and delete the ones that
don't match. I was wondering if someone has a shortcut. Hope I explained it
ok...Thanks.

In other words....2 sets of data, find the matching data (lets say one
cell), on a new sheet, start the list of matching data.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Create a data set from 2 different lists

from which worksheet?

if from sheet1:
Sub ABC()
Dim sh1 as Worksheet, sh2 as Worksheet
Dim sh3 as Worksheet, rng1 as Range
dim rng2 as Range, cell as Range
Dim rw as Long
set sh1 = worksheets("Sheet1")
set sh2 = worksheets("Sheet2")
worksheets.add after:=Worksheets(worksheets.count)
set sh3 = Activesheet
sh3.Name = "Matches"
with sh1
set rng1 = .Range(.cells(2,1),.cells(2,1).End(xldown))
End with

with sh2
set rng2 = .Range(.cells(2,1),.cells(2,1).End(xldown))
End with

rw = 2
for each cell in rng1
if application.Countif(rng2,cell) 0 then
cell.EntireRow.copy sh3.cells(rw,1)
rw = rw + 1
end if
Next
End Sub


If it is from sheet2 you need to copy the data, then just reverse these
lines
set sh1 = worksheets("Sheet1")
set sh2 = worksheets("Sheet2")

becomes
set sh2 = worksheets("Sheet1")
set sh1 = worksheets("Sheet2")

--
Regards,
Tom Ogilvy



"deeds" wrote in message
...
Thanks Tom! That works..however, now, how do I get all of the data with
that
matched figure...in other words, I need the entire row of data that is
with
the matched data, so it finds the match in let's say A1, I also need to
bring
back the other data in that row....any ideas? Thanks again!

"Tom Ogilvy" wrote:

Sub ABC()
Dim sh1 as Worksheet, sh2 as Worksheet
Dim sh3 as Worksheet, rng1 as Range
dim rng2 as Range, cell as Range
Dim rw as Long
set sh1 = worksheets("Sheet1")
set sh2 = worksheets("Sheet2")
worksheets.add after:=Worksheets(worksheets.count)
set sh3 = Activesheet
sh3.Name = "Matches"
with sh1
set rng1 = .Range(.cells(2,1),.cells(2,1).End(xldown))
End with

with sh2
set rng2 = .Range(.cells(2,1),.cells(2,1).End(xldown))
End with

rw = 2
for each cell in rng1
if application.Countif(rng2,cell) 0 then
sh3.cells(rw,1).Value = cell.Value
rw = rw + 1
end if
Next
End Sub

--
Regards,
Tom Ogilvy

"deeds" wrote:

I am trying to create one new list of matching data...I need to look at
one
cell in one sheet and look to another sheet (column) and see if it
shows up
there...if it does, I need to bring back the entire row of data for
that
item...to a new sheet to start the "matching" list. Is there a way to
do
something like this? I have done the vlookup thing and found the data
that
matches....however, now I have to go through sort, and delete the ones
that
don't match. I was wondering if someone has a shortcut. Hope I
explained it
ok...Thanks.

In other words....2 sets of data, find the matching data (lets say one
cell), on a new sheet, start the list of matching data.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Create a data set from 2 different lists

Thanks Tom!....I made this work.....works great!

"Tom Ogilvy" wrote:

from which worksheet?

if from sheet1:
Sub ABC()
Dim sh1 as Worksheet, sh2 as Worksheet
Dim sh3 as Worksheet, rng1 as Range
dim rng2 as Range, cell as Range
Dim rw as Long
set sh1 = worksheets("Sheet1")
set sh2 = worksheets("Sheet2")
worksheets.add after:=Worksheets(worksheets.count)
set sh3 = Activesheet
sh3.Name = "Matches"
with sh1
set rng1 = .Range(.cells(2,1),.cells(2,1).End(xldown))
End with

with sh2
set rng2 = .Range(.cells(2,1),.cells(2,1).End(xldown))
End with

rw = 2
for each cell in rng1
if application.Countif(rng2,cell) 0 then
cell.EntireRow.copy sh3.cells(rw,1)
rw = rw + 1
end if
Next
End Sub


If it is from sheet2 you need to copy the data, then just reverse these
lines
set sh1 = worksheets("Sheet1")
set sh2 = worksheets("Sheet2")

becomes
set sh2 = worksheets("Sheet1")
set sh1 = worksheets("Sheet2")

--
Regards,
Tom Ogilvy



"deeds" wrote in message
...
Thanks Tom! That works..however, now, how do I get all of the data with
that
matched figure...in other words, I need the entire row of data that is
with
the matched data, so it finds the match in let's say A1, I also need to
bring
back the other data in that row....any ideas? Thanks again!

"Tom Ogilvy" wrote:

Sub ABC()
Dim sh1 as Worksheet, sh2 as Worksheet
Dim sh3 as Worksheet, rng1 as Range
dim rng2 as Range, cell as Range
Dim rw as Long
set sh1 = worksheets("Sheet1")
set sh2 = worksheets("Sheet2")
worksheets.add after:=Worksheets(worksheets.count)
set sh3 = Activesheet
sh3.Name = "Matches"
with sh1
set rng1 = .Range(.cells(2,1),.cells(2,1).End(xldown))
End with

with sh2
set rng2 = .Range(.cells(2,1),.cells(2,1).End(xldown))
End with

rw = 2
for each cell in rng1
if application.Countif(rng2,cell) 0 then
sh3.cells(rw,1).Value = cell.Value
rw = rw + 1
end if
Next
End Sub

--
Regards,
Tom Ogilvy

"deeds" wrote:

I am trying to create one new list of matching data...I need to look at
one
cell in one sheet and look to another sheet (column) and see if it
shows up
there...if it does, I need to bring back the entire row of data for
that
item...to a new sheet to start the "matching" list. Is there a way to
do
something like this? I have done the vlookup thing and found the data
that
matches....however, now I have to go through sort, and delete the ones
that
don't match. I was wondering if someone has a shortcut. Hope I
explained it
ok...Thanks.

In other words....2 sets of data, find the matching data (lets say one
cell), on a new sheet, start the list of matching data.




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
Excel -- Data Validation -- Create Dependent Lists Louisa Excel Worksheet Functions 6 October 9th 09 03:27 AM
How to create multiple lists each comprising data from previous li wireman Excel Worksheet Functions 1 September 16th 08 09:20 AM
How to create Dropdown lists not using Data Validation Catlady Excel Discussion (Misc queries) 3 December 13th 06 05:06 PM
How to create lists of data quickly from a pre-existing database TAL27 Excel Discussion (Misc queries) 3 January 5th 06 04:59 PM
Data Validation - Create dependent lists Little pete Excel Discussion (Misc queries) 1 May 23rd 05 12:04 PM


All times are GMT +1. The time now is 02:41 AM.

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"