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

I have 3 worksheets.
One has records of engineering faults. The second a list of fault
numbers and parts used on a repair. The fault number is repeated on as
lines as parts used. The third sheet a detailed list of all
part-descriptions stores location etc.

The below macro (working on double-click on the fault ref. number)
will access the PartsUsed sheet and extract all lines that match a
fault number and assemble in a list the parts used.
So far, so good…. the problem comes when I try to access the third
"Stores Info" sheet "on the fly" to embellish the "list" with
additional info…. ie. Part description, location etc. I have tried
doing another nested "find" but the whole thing falls apart….
Can you do a "nested find" or should I be going about this another
way? Any help appreciated.

Sub DisplayFaultPartsReplaced()
With Sheets("PartsUsed").Range("B3:B" &
Sheets("PartsUsed").Range("B16384").End(xlUp).Row)
Set Itemcode = .Find(ActiveCell.Value,
lookin:=xlValues)
If Not Itemcode Is Nothing Then
firstAddress = Itemcode.Address
Found = -1
Do
Found = Found + 1
Dim StockUsed(15) As Variant
StockUsed(Found) = Itemcode.Offset(0, 2).Value &
"(off) " & Itemcode.Offset(0, 1).Value & " Used"
Parts = Parts & Chr(10) & StockUsed(Found) &
Chr(10)
Set Itemcode = .FindNext(Itemcode)
Loop While Not Itemcode Is Nothing And Itemcode.Address
< firstAddress
End If
End With
Dim Title As String
If Parts = "" Then Parts = "No Parts Used"
Title = "Stock Used on " & ActiveCell.Text
MsgBox Parts, vbInformation, Title

End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Nested Find problem

You can probably us application.Vlookup to retrieve the other information

set rng1 = Worksheets("Stores Info").Range("A1").CurrentRegion

res = application.vlookup(itemcode,rng1,2,false)
if not iserror(res) then
msgbox "item code: " & itemcode & vbcrlf & _
res
else
msgbox "item code: " & itemcode & " not found"
End if


This assumes the item to be looked up is found in column A and you data
table starts in A1.

Regards,
Tom Ogilvy


MikeR wrote in message
om...
I have 3 worksheets.
One has records of engineering faults. The second a list of fault
numbers and parts used on a repair. The fault number is repeated on as
lines as parts used. The third sheet a detailed list of all
part-descriptions stores location etc.

The below macro (working on double-click on the fault ref. number)
will access the PartsUsed sheet and extract all lines that match a
fault number and assemble in a list the parts used.
So far, so good.. the problem comes when I try to access the third
"Stores Info" sheet "on the fly" to embellish the "list" with
additional info.. ie. Part description, location etc. I have tried
doing another nested "find" but the whole thing falls apart..
Can you do a "nested find" or should I be going about this another
way? Any help appreciated.

Sub DisplayFaultPartsReplaced()
With Sheets("PartsUsed").Range("B3:B" &
Sheets("PartsUsed").Range("B16384").End(xlUp).Row)
Set Itemcode = .Find(ActiveCell.Value,
lookin:=xlValues)
If Not Itemcode Is Nothing Then
firstAddress = Itemcode.Address
Found = -1
Do
Found = Found + 1
Dim StockUsed(15) As Variant
StockUsed(Found) = Itemcode.Offset(0, 2).Value &
"(off) " & Itemcode.Offset(0, 1).Value & " Used"
Parts = Parts & Chr(10) & StockUsed(Found) &
Chr(10)
Set Itemcode = .FindNext(Itemcode)
Loop While Not Itemcode Is Nothing And Itemcode.Address
< firstAddress
End If
End With
Dim Title As String
If Parts = "" Then Parts = "No Parts Used"
Title = "Stock Used on " & ActiveCell.Text
MsgBox Parts, vbInformation, Title

End Sub



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
IF nested problem ..! Peter[_14_] Excel Discussion (Misc queries) 2 April 11th 10 01:00 PM
Nested MID and FIND - OR? Brenda Excel Worksheet Functions 3 January 14th 10 01:58 AM
Nested If problem Harish Sharma[_2_] Excel Worksheet Functions 3 August 21st 09 02:25 PM
A problem with Nested IFs The Narcissist Excel Worksheet Functions 0 January 23rd 08 12:12 AM
Nested if problem samonly Excel Worksheet Functions 1 March 14th 06 01:33 PM


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