replicate data based on textsplit result

ExcelNewbie2020

Active Member
Joined
Dec 3, 2020
Messages
289
Office Version
  1. 365
Platform
  1. Windows
Sirs, using excel formula how to replicate data based on the result of of textsplit values.

based on my table below, columns A to E got replicated because of textsplit from column F. thank you


Sample_practice.xlsx
ABCDEF
1NomakeDatecodelocplace
21A2023-03-05ABC123indiauk,us,india
32b2022-12-25DEF245ukmalta,us,uk
43c2022-12-12HIJ256usrus,us
5
6
7
8
9
10
11
12
13expected result
14NomakeDatecodelocplace
151A2023-03-05ABC123indiauk
161A2023-03-05ABC123indiaus
171A2023-03-05ABC123indiaindia
182b2022-12-25DEF245ukmalta
192b2022-12-25DEF245ukus
202b2022-12-25DEF245ukuk
213c2022-12-12HIJ256usrus
223c2022-12-12HIJ256usus
Sheet2
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Hi,

This can be an option if you are OK with VBA:
VBA Code:
Sub test()
  Dim myArray As Variant, tmpArray As Variant, tmpValue As Variant, i As Long, j as long
  myArray = Range("A2:F4")
  ReDim tmpArray(1 To UBound(myArray, 2), 1 To 1)
 
  For i = 1 To UBound(myArray, 1)
    tmpValue = Split(myArray(i, 6), ",")
    For Each tmpVal In tmpValue
      For j = 1 to 5
        tmpArray(j, UBound(tmpArray, 2)) = myArray(i, j)
      Next
      tmpArray(6, UBound(tmpArray, 2)) = tmpVal
      ReDim Preserve tmpArray(1 To UBound(myArray, 2), 1 To UBound(tmpArray, 2) + 1)
    Next
  Next
  ReDim Preserve tmpArray(1 To UBound(myArray, 2), 1 To UBound(tmpArray, 2) - 1)
 
  Range("A15").Resize(UBound(tmpArray, 2), UBound(tmpArray, 1)).Value = Application.Transpose(tmpArray)
End Sub
 
Upvote 0
It's also a built-in function with power query, if that's an option.
 
Upvote 0
Here is a potential formula option:
DatatoChange.xlsx
ABCDEF
1NomakeDatecodelocplace
21A44990ABC123indiauk,us,india
32b44920DEF245ukmalta,us,uk
43c44907HIJ256usrus,us
54d44907daveisrtur,hun
6
7
8
9expected result
10NomakeDatecodelocplace
111A44990ABC123indiauk
121A44990ABC123indiaus
131A44990ABC123indiaindia
142b44920DEF245ukmalta
152b44920DEF245ukus
162b44920DEF245ukuk
173c44907HIJ256usrus
183c44907HIJ256usus
194d44907daveisrtur
204d44907daveisrhun
Sheet3
Cell Formulas
RangeFormula
A11:F20A11=LET( data,A2:F5, n,LEN(TAKE(data,,-1))-LEN(SUBSTITUTE(TAKE(data,,-1),",",""))+1, tc,TOCOL(IF(SEQUENCE(,MAX(n))<=n,BYROW(DROP(data,,-1),LAMBDA(x,TEXTJOIN(",",,x))),#N/A),3), FILTERXML("<t><s>" & SUBSTITUTE(tc&","&TEXTSPLIT(TEXTJOIN(",",,TAKE(data,,-1)),,","),",","</s><s>") & "</s></t>","//s[" & SEQUENCE(,6) & "]") )
Dynamic array formulas.
 
Upvote 0
Solution
Here is a potential formula option:
DatatoChange.xlsx
ABCDEF
1NomakeDatecodelocplace
21A44990ABC123indiauk,us,india
32b44920DEF245ukmalta,us,uk
43c44907HIJ256usrus,us
54d44907daveisrtur,hun
6
7
8
9expected result
10NomakeDatecodelocplace
111A44990ABC123indiauk
121A44990ABC123indiaus
131A44990ABC123indiaindia
142b44920DEF245ukmalta
152b44920DEF245ukus
162b44920DEF245ukuk
173c44907HIJ256usrus
183c44907HIJ256usus
194d44907daveisrtur
204d44907daveisrhun
Sheet3
Cell Formulas
RangeFormula
A11:F20A11=LET( data,A2:F5, n,LEN(TAKE(data,,-1))-LEN(SUBSTITUTE(TAKE(data,,-1),",",""))+1, tc,TOCOL(IF(SEQUENCE(,MAX(n))<=n,BYROW(DROP(data,,-1),LAMBDA(x,TEXTJOIN(",",,x))),#N/A),3), FILTERXML("<t><s>" & SUBSTITUTE(tc&","&TEXTSPLIT(TEXTJOIN(",",,TAKE(data,,-1)),,","),",","</s><s>") & "</s></t>","//s[" & SEQUENCE(,6) & "]") )
Dynamic array formulas.
that worked.. thank you
 
Upvote 0

Forum statistics

Threads
1,215,068
Messages
6,122,950
Members
449,095
Latest member
nmaske

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