Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Comparing two lists

I have two lists, a long list like:

1 itemA
2 itemB
4 itemC
5 itemD

and a short list like:

2 null
4 null

I'm looking for a method that would result in a chopped long list like this:

2 itemB
4 itemC


So, I'd like to automatically compare the lists and as the result remove all
rows from the long list that contain a number in the leftmost cell that is
not present in the leftmost cells of the short list.

In other words, I'd like to remove the row with itemA and the row with itemD
based on the fact that those rows are not present on the second list. (Note
that the number is a value in a cell, not a row number.) How could I manage
this? I'm new with Excel so newbie explanation is appreciated. It doesn't
have to be done in Excel but I thought Excel might be good at this.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Comparing two lists

use countif

C1 of the long list

=if(countif(Sheet2!$A:$A,A1)=1,na(),"")

then drag fill down the column

select C do Edit=goto Special and select formulas and Errors, then do
Edit=Delete and choose entire row.

Delete column C

in code

Dim rng as Range, rng1 as Range
With Worksheets(Sheet1)
set rng = .Range(.Cells(1,1),.Cell(rows.count,1).end(xlup))
End with
rng.offset(0,2).Formula = "=if(countif(Sheet2!$A:$A,A1)=1,na(),"""")"
On Error Resume Next
set rng1 = rng.offset(0,2).specialCells(xlFormulas,xlErrors)
On Error goto 0
if not rng1 is nothing then
rng1.EntireRow.Delete
end if

--
Regards,
Tom ogivy


then drag fill down the column
"Pauli Soininen" wrote in message
...
I have two lists, a long list like:

1 itemA
2 itemB
4 itemC
5 itemD

and a short list like:

2 null
4 null

I'm looking for a method that would result in a chopped long list like

this:

2 itemB
4 itemC


So, I'd like to automatically compare the lists and as the result remove

all
rows from the long list that contain a number in the leftmost cell that is
not present in the leftmost cells of the short list.

In other words, I'd like to remove the row with itemA and the row with

itemD
based on the fact that those rows are not present on the second list.

(Note
that the number is a value in a cell, not a row number.) How could I

manage
this? I'm new with Excel so newbie explanation is appreciated. It doesn't
have to be done in Excel but I thought Excel might be good at this.




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default Comparing two lists

what you want to use is the vlookup. In the function wizard or help, look up
the function VLOOKUP or HLOOKUP, depending on whether the lists are
horizontal or vertical. I would suggest something like this:
=IF(ISERROR(VLOOKUP([reletive cell reference],[absolute
range],1,FALSE)),"Delete Row","Do Nothing")
If you use this function in a column adjacent to the long list, the value
Delete Row will appear next to those rows in the long list which do not
appear in the short list. You could use VBA to automate the deletion of
these rows, but since you are a beginer it'll be easier for you to do
manually.

"Pauli Soininen" wrote:

I have two lists, a long list like:

1 itemA
2 itemB
4 itemC
5 itemD

and a short list like:

2 null
4 null

I'm looking for a method that would result in a chopped long list like this:

2 itemB
4 itemC


So, I'd like to automatically compare the lists and as the result remove all
rows from the long list that contain a number in the leftmost cell that is
not present in the leftmost cells of the short list.

In other words, I'd like to remove the row with itemA and the row with itemD
based on the fact that those rows are not present on the second list. (Note
that the number is a value in a cell, not a row number.) How could I manage
this? I'm new with Excel so newbie explanation is appreciated. It doesn't
have to be done in Excel but I thought Excel might be good at this.



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
comparing lists - i think xeno Excel Discussion (Misc queries) 2 August 18th 06 01:59 PM
Comparing Lists Q Excel Worksheet Functions 1 November 7th 05 09:08 PM
Comparing Lists to Partial Lists depuyus[_7_] Excel Programming 0 August 5th 04 01:43 PM
COMPARING LISTS jay dean Excel Programming 3 June 11th 04 06:00 PM
Comparing 2 Lists Glenn Excel Programming 4 January 19th 04 02:07 PM


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