SOLVED

Convert 912 rows and 16 columns into 2 columns....with a twist

%3CLINGO-SUB%20id%3D%22lingo-sub-1551102%22%20slang%3D%22en-US%22%3EConvert%20912%20rows%20and%2016%20columns%20into%202%20columns....with%20a%20twist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1551102%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20All%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20got%20a%20spreadsheet%20with%20912%20rows%20and%2016%20columns%2C%20each%20is%20row%20contains%20a%20product%20model%20%23%20and%20the%201%20to%2015%20colours%20that%20are%20available%20for%20each%20model.%20I%20need%20to%20convert%20this%20to%20a%20vertical%20set%20up%20with%202%20columns%2C%20Model%23%20and%20Colours%20for%20each%20model.%20Here's%20it's%20current%20setup%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Before.png%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F208543i233119E269F6AA5F%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Before.png%22%20alt%3D%22Before.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EHere's%20an%20example%20what%20we%20need%20the%20final%20to%20look%20like%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22After.png%22%20style%3D%22width%3A%20599px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F208544i8E7564CA17ED7ABB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22After.png%22%20alt%3D%22After.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EAs%20you%20can%20see%20some%20models%20have%20one%20colour%20and%20others%20might%20have%205%2C%2010%20or%2015.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20anyone%20point%20me%20in%20the%20right%20direction%20with%20a%20method%20to%20achieve%20this%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAny%20help%20would%20be%20appreciated.%20Thank%20you!%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPaul%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1551102%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1551276%22%20slang%3D%22en-US%22%3ERe%3A%20Convert%20912%20rows%20and%2016%20columns%20into%202%20columns....with%20a%20twist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1551276%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F279491%22%20target%3D%22_blank%22%3E%40kcb410%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPower%20Query%20works%20-%20name%20the%20range%2C%20query%20it%2C%20select%20first%20column%2C%20Unpivot%20other%20columns%2C%20remove%20Attribute%20column%2C%20return%20result%20back%20to%20Excel%20sheet.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1551304%22%20slang%3D%22en-US%22%3ERe%3A%20Convert%20912%20rows%20and%2016%20columns%20into%202%20columns....with%20a%20twist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1551304%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20the%20reply.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI've%20tried%20using%20unpivot%20other%20but%20I've%20been%20unable%20to%20make%20it%20format%20the%20data%20the%20way%20I%20need%20it.%20For%20instance%20if%20there's%202%20colours%20I%20need%20the%20model%20number%20repeated%20twice%2C%20if%20there's%207%20colours%20I%20need%20the%20model%20number%20repeated%207%20times.%20I%20know%20Power%20Query%20will%20achieve%20this%2C%20I%20just%20don't%20know%20how.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1551443%22%20slang%3D%22en-US%22%3ERe%3A%20Convert%20912%20rows%20and%2016%20columns%20into%202%20columns....with%20a%20twist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1551443%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F279491%22%20target%3D%22_blank%22%3E%40kcb410%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHave%20you%20used%20Macros%20%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20code%20picks%20colors%20from%20right%20to%20each%20product.%3C%2FP%3E%3CP%3EIt%20is%20important%20to%20select%20first%20product-code%20as%20activecell%3C%2FP%3E%3CP%3Ebefore%20running%20this%20code.%3C%2FP%3E%3CP%3ESelect%20first%20product-code%20from%20your%20list%20and%20run%20this%20code.%3C%2FP%3E%3CP%3EYou%20can%20make%20this%20actions%20to%20a%20copy%20of%20your%20original%20data.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20macro%20picks%20up%20colorinformation%20from%20right%20to%20activecell%20(%2014%20columns%20)%3C%2FP%3E%3CP%3Eand%20adds%20a%20row%20for%20new%20color%20if%20needed.%20Macro%20stops%20when%20activecell%20value%3C%2FP%3E%3CP%3Eis%20empty.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESub%20ColumnsToRows()%3C%2FP%3E%3CP%3EDim%20X%20As%20Integer%3CBR%20%2F%3EDim%20Y%20As%20Integer%3C%2FP%3E%3CP%3EY%20%3D%200%3CBR%20%2F%3EDo%20While%20ActiveCell.Value%20%26lt%3B%26gt%3B%20%22%22%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20For%20X%20%3D%202%20To%2015%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20If%20ActiveCell.Offset(0%2C%20X).Value%20%26lt%3B%26gt%3B%20%22%22%20Then%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20ActiveCell.Offset(1%2C%200).EntireRow.Insert%20Shift%3A%3DxlDown%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20ActiveCell.Offset(1%2C%200).Value%20%3D%20ActiveCell.Value%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20ActiveCell.Offset(1%2C%201).Value%20%3D%20ActiveCell.Offset(0%2C%20X).Value%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20Y%20%3D%20Y%20%2B%201%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%26nbsp%3B%20End%20If%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20Next%20X%3C%2FP%3E%3CP%3E%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20ActiveCell.Offset(Y%20%2B%201%2C%200).Select%3CBR%20%2F%3E%26nbsp%3B%26nbsp%3B%20Y%20%3D%200%3C%2FP%3E%3CP%3E%3CBR%20%2F%3ELoop%3C%2FP%3E%3CP%3E%3CBR%20%2F%3EEnd%20Sub%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1551498%22%20slang%3D%22en-US%22%3ERe%3A%20Convert%20912%20rows%20and%2016%20columns%20into%202%20columns....with%20a%20twist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1551498%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F279491%22%20target%3D%22_blank%22%3E%40kcb410%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPlease%20check%20in%20attached%20file%2C%20that's%20just%20two%20steps%20query%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22image.png%22%20style%3D%22width%3A%20372px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F208580i7F1F794F6C11B4C3%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22image.png%22%20alt%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1552287%22%20slang%3D%22en-US%22%3ERe%3A%20Convert%20912%20rows%20and%2016%20columns%20into%202%20columns....with%20a%20twist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1552287%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F279491%22%20target%3D%22_blank%22%3E%40kcb410%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20an%20excamble%20file%20with%20which%20you%20can%20test%20the%20idea.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1552869%22%20slang%3D%22en-US%22%3ERe%3A%20Convert%20912%20rows%20and%2016%20columns%20into%202%20columns....with%20a%20twist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1552869%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you.%20I'll%20try%20this%20file%20later%20today.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1552872%22%20slang%3D%22en-US%22%3ERe%3A%20Convert%20912%20rows%20and%2016%20columns%20into%202%20columns....with%20a%20twist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1552872%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F15762%22%20target%3D%22_blank%22%3E%40Olli%20Haavisto%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you.%20I'll%20take%20a%20look%20at%20this%20file%20later%20today.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1552970%22%20slang%3D%22en-US%22%3ERe%3A%20Convert%20912%20rows%20and%2016%20columns%20into%202%20columns....with%20a%20twist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1552970%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi%20Sergei%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20for%20sending%20that%20file.%3C%2FP%3E%3CP%3EExcuse%20my%20ignorance%20on%20this%20topic%2C%20I've%20never%20used%20Power%20Query.%20I%20assume%20the%20first%20step%20is%20Unpivot%20other%20columns.%20What's%20the%20final%20step%2Fquery%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1553268%22%20slang%3D%22en-US%22%3ERe%3A%20Convert%20912%20rows%20and%2016%20columns%20into%202%20columns....with%20a%20twist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1553268%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F15762%22%20target%3D%22_blank%22%3E%40Olli%20Haavisto%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20testing%20the%20macro%20and%20it's%20repeating%20colours%20and%20shuffling%20the%20order%20for%20some%20reason.%3C%2FP%3E%3CP%3EDo%20you%20have%20any%20idea%20what%20might%20cause%20that%3F%20I've%20attached%20the%20files%20for%20reference.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1553521%22%20slang%3D%22en-US%22%3ERe%3A%20Convert%20912%20rows%20and%2016%20columns%20into%202%20columns....with%20a%20twist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1553521%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F279491%22%20target%3D%22_blank%22%3E%40kcb410%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMaybe%20you%20have%20changed%20selection%20when%20macro%20is%20running%20%3F%20It%20is%20only%20way%20that%20I%20can%20think%3C%2FP%3E%3CP%3Ecould%20cause%20the%20behaviour%20you%20described.%20Run%20macro%20only%20once%20and%20do%20not%20interrupt%20it%20when%3C%2FP%3E%3CP%3Eit%20runs.%20I%20made%20a%20video%2C%20it%20shows%20you%20how%20macro%20proceeds...%3C%2FP%3E%3CP%3Ebut%20video%20format%20is%20not%20allowed%20to%20send%20here.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20run%20any%20macro%20step%20by%20step%20using%20F8%20function%20key.%3C%2FP%3E%3CP%3EFunction%20key%20F5%20runs%20macro%20to%20the%20end%20if%20there%20is%20no%20stopping%20points%20in%20code.%3C%2FP%3E%3CP%3EI%20added%20one%20row%20as%20an%20comment%20to%20code.%20If%20you%20take%20comment-mark%20away%20and%20run%20macro%3C%2FP%3E%3CP%3Eafter%20that%20it%20works%20much%20faster%20without%20updating%20screen%20while%20working.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20is%20fine%20feature%20with%20macros%20that%20a%20person%20can%20make%20them%20work%20in%20so%20many%20ways.%20Implementation%20or%3C%2FP%3E%3CP%3Ethe%20way%20to%20archieve%20the%20goal%20depends%20on%20person%20who%20makes%20the%20code%20and%20his%20imagination.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1553644%22%20slang%3D%22en-US%22%3ERe%3A%20Convert%20912%20rows%20and%2016%20columns%20into%202%20columns....with%20a%20twist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1553644%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F279491%22%20target%3D%22_blank%22%3E%40kcb410%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20may%20open%20the%20file%2C%20Data-%26gt%3BQuery%20and%20Connections%2C%20on%20the%20right%20pane%20double%20click%20on%20query%20(or%20Edit%20from%20right%20click%20menu)%2C%20query%20editor%20will%20be%20opened%2C%20here%20you%20will%20see%20the%20steps%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1554268%22%20slang%3D%22en-US%22%3ERe%3A%20Convert%20912%20rows%20and%2016%20columns%20into%202%20columns....with%20a%20twist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1554268%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F279491%22%20target%3D%22_blank%22%3E%40kcb410%3C%2FA%3E%26nbsp%3B%2C%20here's%20the%20unpivoted%20file%20using%20PQ...%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1558459%22%20slang%3D%22en-US%22%3ERe%3A%20Convert%20912%20rows%20and%2016%20columns%20into%202%20columns....with%20a%20twist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1558459%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F383224%22%20target%3D%22_blank%22%3E%40TheAntony%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks!%20That's%20perfect.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1558494%22%20slang%3D%22en-US%22%3ERe%3A%20Convert%20912%20rows%20and%2016%20columns%20into%202%20columns....with%20a%20twist%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1558494%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F521%22%20target%3D%22_blank%22%3E%40Sergei%20Baklan%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%20for%20the%20help.%20I%20can%20see%20how%20this%20works%20now!%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Contributor

Hello All,

 

I've got a spreadsheet with 912 rows and 16 columns, each is row contains a product model # and the 1 to 15 colours that are available for each model. I need to convert this to a vertical set up with 2 columns, Model# and Colours for each model. Here's it's current setup:

Before.png

Here's an example what we need the final to look like:

 

After.png

As you can see some models have one colour and others might have 5, 10 or 15.

 

Can anyone point me in the right direction with a method to achieve this?

 

Any help would be appreciated. Thank you!

 

Paul

14 Replies

@kcb410 

Power Query works - name the range, query it, select first column, Unpivot other columns, remove Attribute column, return result back to Excel sheet.

@Sergei Baklan 

 

Thanks for the reply.

 

I've tried using unpivot other but I've been unable to make it format the data the way I need it. For instance if there's 2 colours I need the model number repeated twice, if there's 7 colours I need the model number repeated 7 times. I know Power Query will achieve this, I just don't know how.

@kcb410 

 

Have you used Macros ?

 

This code picks colors from right to each product.

It is important to select first product-code as activecell

before running this code.

Select first product-code from your list and run this code.

You can make this actions to a copy of your original data.

 

The macro picks up colorinformation from right to activecell ( 14 columns )

and adds a row for new color if needed. Macro stops when activecell value

is empty.

 

Sub ColumnsToRows()

Dim X As Integer
Dim Y As Integer

Y = 0
Do While ActiveCell.Value <> ""
     For X = 2 To 15
         If ActiveCell.Offset(0, X).Value <> "" Then
               ActiveCell.Offset(1, 0).EntireRow.Insert Shift:=xlDown
               ActiveCell.Offset(1, 0).Value = ActiveCell.Value
               ActiveCell.Offset(1, 1).Value = ActiveCell.Offset(0, X).Value
               Y = Y + 1
        End If
    Next X


   ActiveCell.Offset(Y + 1, 0).Select
   Y = 0


Loop


End Sub

 

@kcb410 

Please check in attached file, that's just two steps query

image.png

@kcb410 

 

Here is an excamble file with which you can test the idea.

 

@Sergei Baklan 

Thank you. I'll try this file later today.

@Olli Haavisto 

Thank you. I'll take a look at this file later today.

@Sergei Baklan 

Hi Sergei,

 

Thanks for sending that file.

Excuse my ignorance on this topic, I've never used Power Query. I assume the first step is Unpivot other columns. What's the final step/query?

 

@Olli Haavisto 

I'm testing the macro and it's repeating colours and shuffling the order for some reason.

Do you have any idea what might cause that? I've attached the files for reference.

 

 

@kcb410 

 

Maybe you have changed selection when macro is running ? It is only way that I can think

could cause the behaviour you described. Run macro only once and do not interrupt it when

it runs. I made a video, it shows you how macro proceeds...

but video format is not allowed to send here.

 

You can run any macro step by step using F8 function key.

Function key F5 runs macro to the end if there is no stopping points in code.

I added one row as an comment to code. If you take comment-mark away and run macro

after that it works much faster without updating screen while working.

 

It is fine feature with macros that a person can make them work in so many ways. Implementation or

the way to archieve the goal depends on person who makes the code and his imagination.

 

 

 

 

 

 

Best Response confirmed by kcb410 (Occasional Contributor)
Solution

@kcb410 

You may open the file, Data->Query and Connections, on the right pane double click on query (or Edit from right click menu), query editor will be opened, here you will see the steps

@kcb410 , here's the unpivoted file using PQ...

@Sergei Baklan 

Thank you for the help. I can see how this works now!