PC Review


Reply
Thread Tools Rate Thread

advanced lookup feature

 
 
Southern at Heart
Guest
Posts: n/a
 
      8th Jan 2008
This may be impossible, but here's what needs to be done.
Sheet1 has a list of parts in column A, & colums B thru F lists components
that make up that part.
Sheet2 column A is a list of components, and I want Column B to list all the
parts (from sheet1!columnA) that use that component.
So in laymens terms, Sheet2B needs to search sheet1B-F and find ALL the
instances of sheet2A. So it may find several parts from sheet 1 that all use
that component, and I need them to be listed in sheet2 next to the component
number
thanks for any help!
 
Reply With Quote
 
 
 
 
carlo
Guest
Posts: n/a
 
      8th Jan 2008
Hey SaH

I wrote you a small sub:
Enter them in a module in your worksheet, change ws_source and
ws_targets name and run "find_comp"
(the function find_range is a courtesy from OZGrid)

'---------------------------------------------------------------------------------
Sub findComp()

Dim ws_source As Worksheet
Dim ws_target As Worksheet

Set ws_source = Worksheets("sheet1")
Set ws_target = Worksheets("sheet2")

ws_target.Range("B1:IV65536").Delete

Dim coll_ As Collection

For i = 1 To ws_target.Cells(65536, 1).End(xlUp).Row
Set coll_ = Return_Items(ws_target.Cells(i, 1), ws_source)

count_ = 2

For Each itm In coll_
ws_target.Cells(i, count_) = itm
count_ = count_ + 1
Next itm

Next i

End Sub

Function Return_Items(Item As String, WS As Worksheet) As Collection

On Error Resume Next

Dim rng As Range
Dim cell_ As Range
Dim temp As New Collection

Set rng = Find_Range(Item, WS.Range("B1:F" & WS.Cells(65536,
1).End(xlUp).Row))

For Each cell_ In rng
temp.Add WS.Cells(cell_.Row, 1), CStr(WS.Cells(cell_.Row, 1))
Next cell_

Set Return_Items = temp

End Function

Function Find_Range(Find_Item As Variant, _
Search_Range As Range, _
Optional LookIn As Variant, _
Optional LookAt As Variant, _
Optional MatchCase As Boolean) As Range

Dim c As Range
If IsMissing(LookIn) Then LookIn = xlValues 'xlFormulas
If IsMissing(LookAt) Then LookAt = xlWhole 'xlPart
If IsMissing(MatchCase) Then MatchCase = False

With Search_Range
Set c = .Find( _
What:=Find_Item, _
LookIn:=LookIn, _
LookAt:=LookAt, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=MatchCase, _
SearchFormat:=False)
If Not c Is Nothing Then
Set Find_Range = c
firstAddress = c.Address
Do
Set Find_Range = Union(Find_Range, c)
Set c = .FindNext(c)
Loop While Not c Is Nothing And c.Address <> firstAddress
End If
End With

End Function
'---------------------------------------------------------------------------------

Pay attention, there might be a wordwrap!!!

hth

Carlo


On Jan 8, 10:31*am, Southern at Heart
<SouthernatHe...@discussions.microsoft.com> wrote:
> This may be impossible, but here's what needs to be done.
> Sheet1 has a list of parts in column A, & colums B thru F lists components
> that make up that part.
> Sheet2 column A is a list of components, and I want Column B to list all the
> parts (from sheet1!columnA) that use that component. *
> So in laymens terms, Sheet2B needs to search sheet1B-F and find ALL the
> instances of sheet2A. *So it may find several parts from sheet 1 that all use
> that component, and I need them to be listed in sheet2 next to the component
> number
> thanks for any help!


 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
advanced edit feature missing LeAnne Microsoft Outlook Discussion 4 17th Aug 2008 04:36 AM
Issue when creating Signature using Advanced Edit feature =?Utf-8?B?U2FyYWw2OTc4?= Microsoft Outlook Discussion 0 25th Sep 2007 08:38 PM
RE: Advanced Lookup (lookup for 2 values) =?Utf-8?B?dGp0amp0anQ=?= Microsoft Excel Worksheet Functions 1 30th Mar 2006 07:09 PM
Search Advanced Feature Andrew Ofthesong Windows XP Basics 6 26th Nov 2004 05:24 PM
Outlook 2000 Advanced Find feature James Smith Microsoft Outlook 0 24th Nov 2003 02:45 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:43 AM.