Process to Match IDs to Multiple Cells Based off of Another Cell?

CtrlAltRage

New Member
Joined
Aug 23, 2022
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Hey all,

I'm not entirely sure if this is a VBA question or a macro or formula I can use. But here's what I'm trying to do.

I have two files, we'll call them File 1 and File 2.

In File One, there are 3 Columns:

ID, Name, Title IDs

ID and Name have one entry in their respective cells. Title IDs may have multiple IDs separated by commas (0013,0014,0015, etc)

Example:

IDNameTitle IDs
01John Smith0012,0034,0090
02Jane Doe0012,0078,0090,0100

In File Two, there are two columns:

Title ID, Title Name

Each column in File Two have one Entry.

Example:

Title IDTitle Name
0012Name 1
0034Name 2
0078Name 3
0090Name 4
0100Name 5

What I'm trying to do is take those two files, and combine them into one new file where it populates the IDs from File One and matches them to the respective Title IDs of File Two in individual cells.

Example:

IDTitle ID
010012
020012
010034
020078
010090
020090
020100

I hope what I'm trying to convey is making sense - right now splitting the Title IDs in File One is not an option, so ideally I need to create a new file for it.

Any help and insight would be appreciated, thank you!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
I'm unsure what File Two has to do with it? From what you describe that final result is obtainable from File One only.
For example, if you have the required functions, isn't this doing what you asked?

22 12 24.xlsm
ABCDEF
1IDNameTitle IDsIDTitle ID
201John Smith0012,0034,0090010012
302Jane Doe0012,0078,0090,0100020012
4010034
5020078
6010090
7020090
8020100
9
Split IDs
Cell Formulas
RangeFormula
E2:F8E2=SORT(WRAPROWS(TEXTSPLIT(TEXTJOIN(",",,BYROW(A2:C3,LAMBDA(a,INDEX(a,1)&","&SUBSTITUTE(INDEX(a,3),",",","&INDEX(a,1)&",")))),","),2),2)
Dynamic array formulas.
 
Upvote 0
VBA Code:
Sub string_er()
       Dim store() As String
       Dim k, j As Integer
       Dim lr As Long
       Dim wk1, wk2 As Worksheet
       Dim number As String
       Set wk1 = Sheets("sheet23") 'input sheet name
       Set wk2 = Sheets("sheet24") ' ouput sheet name
       lr = wk1.Cells(Rows.Count, 1).End(xlUp).Row
        For k = 2 To lr
            store = Split(wk1.Range("C" & k), ",")
                number = wk1.Range("A" & k)
                For j = 0 To UBound(store)
                        wk2.Range("B:B").NumberFormat = "@"
                        wk2.Cells(Rows.Count, 2).End(xlUp).Offset(1, 0) = store(j)
                        wk2.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) = number
                Next j
        Next k
End Sub
 

Attachments

  • 1671879706494.png
    1671879706494.png
    87.7 KB · Views: 13
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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