Hi,
I adapted that code from the Excel help example for the Find function and from a guy from a forum somewhere.
I want to transform that kind of BOM to a multi level BOM.
'This is from a guy looking for the same thing on another forum.
FG1|SA1|1
FG2|SA2|1
FG1|CO1|4
SA1|SA3|2
SA1|CO2|3
SA3|CO3|2
SA2|SA3|4
SA2|CO4|1
FG1|FG1|SA1
FG1|SA1|SA3
FG1|SA3|CO3
FG1|SA1|CO2
FG1|FG1|CO1
FG2|FG1|SA2
FG2|SA2|SA3
FG2|SA3|CO3
FG2|SA2|CO4
I'm calling it like that.
My problem is when it doesn't find a value within the 2nd call, returns to the previous one, c is nothing, which shouldn't be the case!!
Thanks for helping.
I adapted that code from the Excel help example for the Find function and from a guy from a forum somewhere.
I want to transform that kind of BOM to a multi level BOM.
'This is from a guy looking for the same thing on another forum.
FG1|SA1|1
FG2|SA2|1
FG1|CO1|4
SA1|SA3|2
SA1|CO2|3
SA3|CO3|2
SA2|SA3|4
SA2|CO4|1
FG1|FG1|SA1
FG1|SA1|SA3
FG1|SA3|CO3
FG1|SA1|CO2
FG1|FG1|CO1
FG2|FG1|SA2
FG2|SA2|SA3
FG2|SA3|CO3
FG2|SA2|CO4
Code:
Function find1(item)
Dim strFirstAddress As String
Set c = Worksheets("Format").range("B:B").Find(item)
If Not c Is Nothing Then
strFirstAddress = c.Address
Do
'debug
c.Select
c.Offset(0, 1).Select
'find the next assembly (calling itself)
find1 (c.Offset(0, 1).Value)
'Come back and findnext previous value
Set c = Worksheets("Format").range("B:B").FindNext(c)
Loop While c.Address <> strFirstAddress
Else
Debug.Print "Cells Not Found"
End If
End Function
I'm calling it like that.
Code:
sub test()
For Each c In range("B:B")
c.Select
If c.Value = 1 Then
newSubAssy = c.Offset(0, 1).Value
find1 (newSubAssy)
End If
Next c
End Sub
My problem is when it doesn't find a value within the 2nd call, returns to the previous one, c is nothing, which shouldn't be the case!!
Thanks for helping.
Last edited: