ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Parent/Child Macro (https://www.excelbanter.com/excel-programming/398484-parent-child-macro.html)

turtle[_2_]

Parent/Child Macro
 
I am looking to get some big time help on writing a macro or formula
to fill out the parent id based on the child id. I have filled out
some of the parent id's to show how it should look. Basically the
parent id follows a general wbs structure where .01.01 would be the
parent of .01.01.01. Any help would be fantastic.
thanks

Child id Parent id
V/0047.FNG.01.01
V/0047.FNG.01.01.01 V/0047.FNG.01.01
V/0047.FNG.01.02 V/0047.FNG.01
V/0047.FNG.01.02.01 V/0047.FNG.01.02
V/0047.FNG.01.03 V/0047.FNG.01
V/0047.FNG.01.03.01 V/0047.FNG.01.03
V/0047.FNG.01.03.02 V/0047.FNG.01.03
V/0047.FNG.01.03.03 V/0047.FNG.01.03
V/0047.FNG.01.03.04 V/0047.FNG.01.03
V/0047.FNG.01.03.05 V/0047.FNG.01.03
V/0047.FNG.01.03.06 V/0047.FNG.01.03
V/0047.FNG.01.04
V/0047.FNG.01.04.01
V/0047.FNG.01.04.02
V/0047.FNG.01.04.03
V/0047.FNG.01.04.04
V/0047.FNG.01.05


Chip Pearson

Parent/Child Macro
 
Is the Parent *ALWAYS* the same as the Child except that the last ".nn" is
missisng?

Function ParentCode(ChildCode As String) As String
If Len(ChildCode) <= 16 Then
ParentCode = vbNullString
Else
ParentCode = Left(ChildCode, Len(ChildCode) - 3)
End If
End Function

or if length of the code doesn't matter, use just

Function ParentCode(ChildCode As String) As String
ParentCode = Left(ChildCode, Len(ChildCode) - 3)
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting
www.cpearson.com
(email on the web site)


"turtle" wrote in message
ups.com...
I am looking to get some big time help on writing a macro or formula
to fill out the parent id based on the child id. I have filled out
some of the parent id's to show how it should look. Basically the
parent id follows a general wbs structure where .01.01 would be the
parent of .01.01.01. Any help would be fantastic.
thanks

Child id Parent id
V/0047.FNG.01.01
V/0047.FNG.01.01.01 V/0047.FNG.01.01
V/0047.FNG.01.02 V/0047.FNG.01
V/0047.FNG.01.02.01 V/0047.FNG.01.02
V/0047.FNG.01.03 V/0047.FNG.01
V/0047.FNG.01.03.01 V/0047.FNG.01.03
V/0047.FNG.01.03.02 V/0047.FNG.01.03
V/0047.FNG.01.03.03 V/0047.FNG.01.03
V/0047.FNG.01.03.04 V/0047.FNG.01.03
V/0047.FNG.01.03.05 V/0047.FNG.01.03
V/0047.FNG.01.03.06 V/0047.FNG.01.03
V/0047.FNG.01.04
V/0047.FNG.01.04.01
V/0047.FNG.01.04.02
V/0047.FNG.01.04.03
V/0047.FNG.01.04.04
V/0047.FNG.01.05




All times are GMT +1. The time now is 03:29 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com