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

Hello -

I am having a bit of trouble looking up and returning certain values
in multiple collections. Here is an example of my situation: I have
100 values in a single column range (Collection1) and 20 values in a
second single column range (Collection2). I would like to lookup the
values in Collection2 and determine if they exist in Collection1. If
they do not exist, I want to be able to capture them in a separate
worksheet. (An exception report if you will) It is fairly easy to
determine if they do exist but my main problem is handling the cases
where a match does not exist and an error results. Does anyone know
of an efficient way to handle the errors and capture the unmatched
data?

Collection1 is essentially a list of open cost centers and Collection2
is a list of cost centers that have been charged to in the past month.
I want to be able to determine if there are any cost centers being
charged to that are not currently open (i.e in collection1) and
display them in a separate sheet as an exception report.

Any help is greatly appreciated.

Dave
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Collections Lookups

I assun=me that one uses the VLOOKUP function for this as
its probably the easiest. The issue is that is the
function fails to find a match, it generates an error. I
usually "wrap" this in a function that returns True or
False, or the index or a zero....
for example

Sub Test()
'' dim the collection etc first !

For Each Item in Collection2

If MissingItem(Item) then
ProcessNewItem Item
End If

Next

End Sub

Private Function MissingItem(Item) as Boolean
dim index as Long
' set a trap for the error
On Error Resume Next
Index = _
Application.WorksheetFunction.Match
(Item,ollection1,False)
' test error
If Err.Number = 0 Then
' OK
MissingItem = False
Else
Err.Clear
MissingItem = True
End If
' reset the error trap
On Error Goto 0
End Function


HTH
Patrick Molloy
Microsoft Excel MVP

-----Original Message-----
Hello -

I am having a bit of trouble looking up and returning

certain values
in multiple collections. Here is an example of my

situation: I have
100 values in a single column range (Collection1) and 20

values in a
second single column range (Collection2). I would like

to lookup the
values in Collection2 and determine if they exist in

Collection1. If
they do not exist, I want to be able to capture them in

a separate
worksheet. (An exception report if you will) It is

fairly easy to
determine if they do exist but my main problem is

handling the cases
where a match does not exist and an error results. Does

anyone know
of an efficient way to handle the errors and capture the

unmatched
data?

Collection1 is essentially a list of open cost centers

and Collection2
is a list of cost centers that have been charged to in

the past month.
I want to be able to determine if there are any cost

centers being
charged to that are not currently open (i.e in

collection1) and
display them in a separate sheet as an exception report.

Any help is greatly appreciated.

Dave
.

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
minimize the file size in a ppt with collections of many pivot tables chermaine Excel Discussion (Misc queries) 1 December 30th 05 11:04 AM
LOOKUPS - Creating LOOKUPs where two different values must BOTH be satisfied. Mr Wiffy Excel Worksheet Functions 2 May 16th 05 04:29 AM
Comparing Collections Tom Ogilvy Excel Programming 1 September 17th 03 06:15 PM
Intersecting/Unioning Collections Robbie[_2_] Excel Programming 3 September 13th 03 08:09 PM
Creating Collections 'on the fly' Dave Peterson[_3_] Excel Programming 4 September 6th 03 07:20 AM


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