Creating Parent - Child Data [VBA]

DataBlake

Well-known Member
Joined
Jan 26, 2015
Messages
781
Office Version
  1. 2016
Platform
  1. Windows
Hello all,
I'd be super glad if someone could help me come up with a way to create multiple part numbers using two qualifiers from a single line
so lets say i have this product which would be the parent on Sheet1

partnumbrandstylecolorsize1size2size3anglereverse anglepattern
D4563TrianGlumBlack223932-173.556x110

<tbody>
</tbody>

and then i have a on a different sheet (TitleHelper) a list of variation identifiers

PatternAngle MinAngle MaxID1IDShortID Code
6x110-200ColorisColC1
6x110-155FlorisFloF1
6x110-30-10ProbisProP1
6x110-50100SlotisSloS1

<tbody>
</tbody>

and here is where i run into my problem is i need to create a new partnum with "*ID Code" for every time this item matches the pattern and the pattern is within min-max. So something like this:

Code:
=IF(AND(J2=TitleHelper!A2,H2<=TitleHelper!C2,H2>=TitleHelper!B2),A2&"*"&TitleHelper!F2)

except for every instance that the pattern matches, and the angle is within the range of min-max it inserts the new part number below the parent part number so Sheet1 would look like

partnumbrandstylecolorsize1size2size3anglereverse anglePattern
D4563TrianGlumBlack223932-173.556x110
D4563*C1TrianGlumBlack223932-173.556x110
D4563*P1TrianGlumBlack223932-173.556x110
D4563*S1TrianGlumBlack223932-173.556x110

<tbody>
</tbody>

*Note that there are 19 columns of important info to copy down to child partnums not just 10
*Note that I will love you forever if you help me, and if you leave me notes to learn
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
yeah i've tried to think this out in what i know of VBA and i can't seem to get it right.
my brain turns to static whenever i get around to thinking about the multiple match part/the insert part

Code:
Sub parentCHILD()
Dim childROW As Long
Dim parentROW As Long
Dim childPATTERN As Range
Dim oMAX As Range
Dim oMIN As Range
Dim parentPATTERN As Range
Dim parentPATTERN2 As Range
Dim parentANGLE As Range
Dim i As Long

With Sheets("TitleHelper")
Set childROW = Cells(Rows.Count, 1).End(xlUp).Row
Set childPATTERN = Range("A" & childROW)
Set oMAX = Range("B" & childROW)
Set oMIN = Range("C" & childROW)
End With


With Sheets("Sheet1")
Set parentRow = Cells(Rows.Count, 1).End(xlUp).Row
Set parentPATTERN = Range("J" & parentROW)
Set parentPATTERN2 = Range("K" & parentROW)
Set parentANGLE = Range("H" & parentROW)

For i = 1 To childROW
[COLOR=#ff0000]if parentPATTERN or parentPATTERN2 = childPATTERN and parentANGLE <= oMAX and parentANGLE >= oMIN then . . .[/COLOR]
Next i
End With

End Sub

this is what i have so far
red indicates brain fart
 
Last edited:
Upvote 0
i got an index array formula working to where it takes the Parent Pattern in Sheet1 & it gives me the new part number i want, but i don't know how to incorporate it into VBA to where it says autofill until error or something. Anyways here is the formula.

In sheet1 cell A3 and then autofilled down 2 more rows
Code:
{=$A$2&"*"&IFERROR(INDEX(TitleHelper!$F$2:$F$15, SMALL(IF(ISNUMBER(MATCH(TitleHelper!$A$2:$A$15, $J$1, 0)), MATCH(ROW(TitleHelper!$A$2:$A$15), ROW(TitleHelper!$A$2:$A$15)), ""), ROWS($A$1:A1))),"err")}
 
Last edited:
Upvote 0
Hello BlakeSkate,

Just so I understand, you want a VBA macro to extend the pattern matches for the current part numbers. Am I correct?
 
Upvote 0
you want a VBA macro to extend the pattern matches for the current part numbers. Am I correct?


i think so?
its literally just if the pattern from sheet1 (column J)
matches the pattern of TitleHelper (column A)

and the angle from Sheet1 (column H)
is in between the Minimum and Maximum angle from TitleHelper (columns B & C)

it will put all of the matches' ID Codes from TitleHelper (column F)
onto the end of the partnum from Sheet1 (Column A)
and insert a row below the original partnum for each match

and then move on to the next partnum/row

its literally like if you have a shoe and the shoe came in different sizes so you wanted unique identifiers. so adding the sizes at the end of the part number for that shoe.
slightly different but i hope that illustrates what i want.

If you recreate everything in post 1 it should check out.
I appreciate the help
 
Upvote 0
and to clarify: the first table is sheet1
the second table is TitleHelper
and the third table is the desired result in sheet1
 
Last edited:
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,614
Members
449,091
Latest member
gaurav_7829

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top