Avatar of Fauzie Bachri
Fauzie Bachri
 asked on

Vba Macro to transform Table data format

Dear Experts,

Anyone can help me for a macro code in excel to transform data like below

Name       Detail1   Detail2      Detail3
ABC           A            A1,A2       B1
DEF            A            C1             C2,C3
GHI             C             D1             D2


to below

Name       Detail1   Detail2      Detail3
ABC           A            A1             B1
ABC           A            A2             B1
DEF            A            C1             C2
DEF            A            C1             C3
GHI             C             D1             D2

Thank you
Regards,
Fauzie
VBAMicrosoft ExcelMicrosoft Office

Avatar of undefined
Last Comment
Fauzie Bachri

8/22/2022 - Mon
Martin Liss

Click the 'Transform' button in the attached workbook.
29214632.xlsm
Fauzie Bachri

ASKER
Hi Martin,

Thank you for the solution, apology i missed to mention that in my real data, the data with comma separated is flexible
currently your code will only separate the first 2 data, so for data like below

 
NameDetail1Detail2Detail3
N1A1A1, A2, A3A1, A2, A3
N2A1A1 A2

will be transformed to this
 
NameDetail1Detail2Detail3
N1A1A1A1
N1A1A1 A2
N1A1 A2A1, A2, A3
N2A1A1 A2

while it should be like this

 
NameDetail1Detail2Detail3
N1A1A1A1
N1A1A1A2
N1A1A1A3
N1A1A2A1
N1A1A2A2
N1A1A2A3
N1A1A3A1
N1A1A3A2
N1A1A3A3
N2A1A1 A2

Really appreciate if your code can be modified so it can transform the data correctly

Thank you in advance for your help


Regards,
Fauzie
ASKER CERTIFIED SOLUTION
Martin Liss

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Fauzie Bachri

ASKER
Thank you very much Martin, your VBA code works flawlessly. its save a lot of time to transform my data :)
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
Martin Liss

You’re welcome and I’m glad I was able to help.

If you expand the “Full Biography" section of my profile you’ll find links to some articles I’ve written that may interest you.

Marty - Microsoft MVP 2009 to 2017
              Experts Exchange Most Valuable Expert (MVE) 2015, 2017
              Experts Exchange Distinguished Expert in Excel 2018
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2020
              Experts Exchange Top Expert VBA 2018 to 2020
Fauzie Bachri

ASKER
Thank you