SOLVED
Home

How would I sort/filter this example? Excel 2016

%3CLINGO-SUB%20id%3D%22lingo-sub-827743%22%20slang%3D%22en-US%22%3EHow%20would%20I%20sort%2Ffilter%20this%20example%3F%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-827743%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20924px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F128970i73D194EAB5F2B788%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Excel%20Example.png%22%20title%3D%22Excel%20Example.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EHello%20guys%2C%20I'm%20in%20need%20of%20some%20excel%20expertise.%20I've%20attached%20a%20sample%20picture%20of%20what%20my%20current%20spreadsheet%20looks%20like.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EWhat%20I'm%20trying%20to%20do%3A%26nbsp%3B%20%3C%2FSTRONG%3EI%20have%20multiple%20abbreviations%20with%20an%20amount%20under%20columns%20B%20through%20G.%26nbsp%3B%3C%2FP%3E%3CP%3EI'm%20trying%20to%20sort%20all%20the%20JACM%2FCLAM%2FWYAK%2Fetc%20and%20the%20numbers%20below%20them%20into%20their%20own%20column%2C%26nbsp%3B%20and%20I'm%20having%20alot%20of%20trouble%20doing%20so.%20I%20want%20Column%20B%20to%20be%20all%20JACM%2C%20C%20to%20be%20all%20WYAK%2C%20etc%20but%20still%20be%20lined%20up%20on%20correct%20guys%20under%20row%20A.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%20sorry%20for%20the%20confusing%20explanation%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-827743%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-828345%22%20slang%3D%22en-US%22%3ERe%3A%20How%20would%20I%20sort%2Ffilter%20this%20example%3F%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-828345%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F377119%22%20target%3D%22_blank%22%3E%40Paneross%3C%2FA%3E%26nbsp%3BThe%20problem%20here%20is%20that%20you%20have%20entered%20data%20into%20a%20report%20structure%2C%20and%20on%20top%20of%20that%20used%20inconsistent%20column%20patterns.%20This%20data%20is%20now%20really%20hard%20to%20handle%2C%20and%20re-arranging%20it%20will%20be%20tedious%20and%20most%20likely%2C%20manual.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EA%20far%20better%20data%20entry%20structure%20would%20be%20just%20three%20columns%2C%20i.e.%20name%2C%20type%2C%20and%20value.%20From%20such%20a%20flat%20table%20you%20can%20then%20easily%20build%20the%20desired%20report%20with%20the%20data%20arranged%20as%20you%20describe.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-828507%22%20slang%3D%22en-US%22%3ERe%3A%20How%20would%20I%20sort%2Ffilter%20this%20example%3F%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-828507%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F377119%22%20target%3D%22_blank%22%3E%40Paneross%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20used%20VBA%20approach%20to%20get%20the%20data%20in%20the%20desired%20format.%3C%2FP%3E%3CP%3EIn%20the%20attached%2C%20click%20the%20button%20called%20%22Transform%20Data%22%20on%20Sheet1%20to%20run%20the%20code.%20You%20will%20be%20prompted%20to%20select%20the%20range%20with%20data%20and%20the%20code%20will%20insert%20a%20new%20sheet%20called%20%22Output%22%20with%20the%20data%20in%20the%20desired%20format.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3ESub%20TransformData()%0ADim%20wsOutput%20%20%20%20As%20Worksheet%0ADim%20rng%20%20%20%20%20%20%20%20%20As%20Range%0ADim%20x%20%20%20%20%20%20%20%20%20%20%20As%20Variant%0ADim%20y()%20%20%20%20%20%20%20%20%20As%20Variant%0ADim%20i%20%20%20%20%20%20%20%20%20%20%20As%20Long%0ADim%20j%20%20%20%20%20%20%20%20%20%20%20As%20Long%0ADim%20r%20%20%20%20%20%20%20%20%20%20%20As%20Long%0ADim%20c%20%20%20%20%20%20%20%20%20%20%20As%20Long%0ADim%20n%20%20%20%20%20%20%20%20%20%20%20As%20Variant%0A%0AOn%20Error%20Resume%20Next%0ASet%20rng%20%3D%20Application.InputBox(%22Please%20select%20the%20Range%20with%20Data.%22%2C%20Type%3A%3D8)%0A%0AIf%20rng%20Is%20Nothing%20Then%0A%20%20%20%20MsgBox%20%22You%20didn't%20select%20any%20Range.%22%2C%20vbExclamation%0A%20%20%20%20Exit%20Sub%0AEnd%20If%0A%0AApplication.ScreenUpdating%20%3D%20False%0AApplication.DisplayAlerts%20%3D%20False%0A%0AThisWorkbook.Worksheets(%22Output%22).Delete%0AOn%20Error%20GoTo%200%0A%0Ax%20%3D%20rng.Value%0AReDim%20y(1%20To%20UBound(x%2C%201)%20*%20UBound(x%2C%202)%2C%201%20To%201)%0A%0Ar%20%3D%201%0Ac%20%3D%201%0A%0AFor%20i%20%3D%201%20To%20UBound(x%2C%201)%0A%20%20%20%20For%20j%20%3D%202%20To%20UBound(x%2C%202)%0A%20%20%20%20%20%20%20%20If%20IsNumeric(x(i%2C%20j))%20And%20x(i%2C%20j)%20%26gt%3B%200%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20n%20%3D%20Application.Match(x(i%20-%201%2C%20j)%2C%20Application.Index(y%2C%201%2C%200)%2C%200)%0A%20%20%20%20%20%20%20%20%20%20%20%20If%20IsError(n)%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20r%20%3D%20r%20%2B%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20c%20%3D%20c%20%2B%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ReDim%20Preserve%20y(1%20To%20UBound(x%2C%201)%20*%20UBound(x%2C%202)%2C%201%20To%20c)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20y(r%2C%201)%20%3D%20x(i%20-%201%2C%201)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20y(1%2C%20c)%20%3D%20x(i%20-%201%2C%20j)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20y(r%2C%20c)%20%3D%20x(i%2C%20j)%0A%20%20%20%20%20%20%20%20%20%20%20%20Else%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20r%20%3D%20r%20%2B%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20y(r%2C%201)%20%3D%20x(i%20-%201%2C%201)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20y(r%2C%20n)%20%3D%20x(i%2C%20j)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20Next%20j%0ANext%20i%0ASet%20wsOutput%20%3D%20ThisWorkbook.Worksheets.Add(after%3A%3Drng.Parent)%0AwsOutput.Name%20%3D%20%22Output%22%0AWith%20wsOutput.Range(%22A1%22).Resize(r%2C%20c)%0A%20%20%20%20.Value%20%3D%20y%0A%20%20%20%20.NumberFormat%20%3D%20%220.00%22%0A%20%20%20%20.Columns(1).AutoFit%0A%20%20%20%20.Borders.Color%20%3D%20vbBlack%0AEnd%20With%0A%0AApplication.DisplayAlerts%20%3D%20True%0AApplication.ScreenUpdating%20%3D%20True%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%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-828944%22%20slang%3D%22en-US%22%3ERe%3A%20How%20would%20I%20sort%2Ffilter%20this%20example%3F%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-828944%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%20that%20was%20exactly%20what%20I%20was%20looking%20for!%20Thank%20you%20so%20much%2C%20you%20don't%20realize%20how%20much%20this%20will%20help%20now%20and%20in%20the%20future.%20I%20truly%20appreciate%20it!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-828953%22%20slang%3D%22en-US%22%3ERe%3A%20How%20would%20I%20sort%2Ffilter%20this%20example%3F%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-828953%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F377119%22%20target%3D%22_blank%22%3E%40Paneross%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20an%20optimum%20situation%20for%20using%20Power%20Query%2C%20just%20few%20clicks.%3C%2FP%3E%3CP%3EGood%20luck%3C%2FP%3E%3CP%3ENabil%20Mourad%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-828986%22%20slang%3D%22en-US%22%3ERe%3A%20How%20would%20I%20sort%2Ffilter%20this%20example%3F%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-828986%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F377119%22%20target%3D%22_blank%22%3E%40Paneross%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou're%20welcome!%20Glad%20it%20worked%20as%20desired!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-828995%22%20slang%3D%22en-US%22%3ERe%3A%20How%20would%20I%20sort%2Ffilter%20this%20example%3F%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-828995%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F365248%22%20target%3D%22_blank%22%3E%40nabilmourad%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CBLOCKQUOTE%3E%3CHR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F365248%22%20target%3D%22_blank%22%3E%40nabilmourad%3C%2FA%3E%26nbsp%3Bwrote%3A%3CP%3EThis%20is%20an%20optimum%20situation%20for%20using%20Power%20Query%2C%20just%20few%20clicks.%3C%2FP%3E%3C%2FBLOCKQUOTE%3E%3CP%3EThis%20is%20absolutely%20pointless%20to%20criticize%20the%20accepted%20solution%20instead%20of%20posting%20your%20own%20solution.%2C%20that%20makes%20no%20sense.%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-829057%22%20slang%3D%22en-US%22%3ERe%3A%20How%20would%20I%20sort%2Ffilter%20this%20example%3F%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-829057%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%20You've%20been%20a%20great%20help%2C%20would%20you%20mind%20helping%20with%20this%20last%20question%20then%20I%20think%20I'll%20be%20set%20for%20a%20very%20long%20time.%20Now%20that%20I%20got%20the%20data%20sorted%20using%20the%20code%20provided%2C%20I've%20noticed%20I%20have%20duplicates%2C%20(see%20example%20%22Problem%20Table%22)%2C%20now%20I'm%20trying%20to%20merge%20multiple%20entries%20in%20Column%20A%2C%20with%20the%20B%3AM%20data%20into%20one%20row.%20I've%20tried%20merging%2C%20subtotaling%2C%20and%20played%20with%20a%20pivot%20table%20and%20wasn't%20able%20to%20merge%20the%20rows%2C%20and%20get%20rid%20of%20the%20duplicates.%20Thanks!%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F129088i428162A944AD1A21%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22Problem%20Table.png%22%20title%3D%22Problem%20Table.png%22%20%2F%3E%3C%2FSPAN%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F129087iAE1BC5E43CECACD1%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22End%20Goal.png%22%20title%3D%22End%20Goal.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-829259%22%20slang%3D%22en-US%22%3ERe%3A%20How%20would%20I%20sort%2Ffilter%20this%20example%3F%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-829259%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20you%20show%20me%20where%20I%20criticized%20your%20solution%3F%3C%2FP%3E%3CP%3EI%20am%20reporting%20this%20comment%20as%20a%20rude%20comment.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-829490%22%20slang%3D%22en-US%22%3ERe%3A%20How%20would%20I%20sort%2Ffilter%20this%20example%3F%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-829490%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3BHello%2C%20our%20moderation%20team%20has%20reviewed%20this%20and%20seems%20like%20a%20misunderstanding.%20Offering%20different%20advice%20to%20what's%20been%20accepted%20is%20not%20the%20same%20as%20criticizing%20that%20previous%20advice.%20Check%20out%20our%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FCommunity-Guidelines%2FMicrosoft-Tech-Community-Code-of-Conduct%2Fm-p%2F31390%23M14%22%20target%3D%22_self%22%3Ecode%20of%20conduct%3C%2FA%3E%26nbsp%3Bif%20you%20have%20any%20questions.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-829528%22%20slang%3D%22en-US%22%3ERe%3A%20How%20would%20I%20sort%2Ffilter%20this%20example%3F%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-829528%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F41707%22%20target%3D%22_blank%22%3E%40Eric%20Starker%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESorry%20Eric%20if%20I%20violated%20the%20code%20of%20conduct.%20Please%20accept%20my%20apologies.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-830010%22%20slang%3D%22en-US%22%3ERe%3A%20How%20would%20I%20sort%2Ffilter%20this%20example%3F%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-830010%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F377119%22%20target%3D%22_blank%22%3E%40Paneross%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIn%20that%20case%2C%20you%20may%20try%20this...%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-markup%22%3E%3CCODE%3ESub%20TransformData()%0ADim%20wsOutput%20%20%20%20As%20Worksheet%0ADim%20rng%20%20%20%20%20%20%20%20%20As%20Range%0ADim%20x%20%20%20%20%20%20%20%20%20%20%20As%20Variant%0ADim%20y()%20%20%20%20%20%20%20%20%20As%20Variant%0ADim%20i%20%20%20%20%20%20%20%20%20%20%20As%20Long%0ADim%20j%20%20%20%20%20%20%20%20%20%20%20As%20Long%0ADim%20r%20%20%20%20%20%20%20%20%20%20%20As%20Long%0ADim%20c%20%20%20%20%20%20%20%20%20%20%20As%20Long%0ADim%20n%20%20%20%20%20%20%20%20%20%20%20As%20Variant%0ADim%20m%20%20%20%20%20%20%20%20%20%20%20As%20Variant%0A%0AOn%20Error%20Resume%20Next%0ASet%20rng%20%3D%20Application.InputBox(%22Please%20select%20the%20Range%20with%20Data.%22%2C%20Type%3A%3D8)%0A%0AIf%20rng%20Is%20Nothing%20Then%0A%20%20%20%20MsgBox%20%22You%20didn't%20select%20any%20Range.%22%2C%20vbExclamation%0A%20%20%20%20Exit%20Sub%0AEnd%20If%0A%0AApplication.ScreenUpdating%20%3D%20False%0AApplication.DisplayAlerts%20%3D%20False%0A%0AThisWorkbook.Worksheets(%22Output%22).Delete%0AOn%20Error%20GoTo%200%0A%0Ax%20%3D%20rng.Value%0AReDim%20y(1%20To%20UBound(x%2C%201)%20*%20UBound(x%2C%202)%2C%201%20To%201)%0A%0Ar%20%3D%201%0Ac%20%3D%201%0A%0AFor%20i%20%3D%201%20To%20UBound(x%2C%201)%0A%20%20%20%20For%20j%20%3D%202%20To%20UBound(x%2C%202)%0A%20%20%20%20%20%20%20%20If%20IsNumeric(x(i%2C%20j))%20And%20x(i%2C%20j)%20%26gt%3B%200%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20If%20i%20%26gt%3B%201%20Then%20m%20%3D%20Application.Match(x(i%20-%201%2C%201)%2C%20Application.Index(y%2C%200%2C%201)%2C%200)%0A%20%20%20%20%20%20%20%20%20%20%20%20n%20%3D%20Application.Match(x(i%20-%201%2C%20j)%2C%20Application.Index(y%2C%201%2C%200)%2C%200)%0A%20%20%20%20%20%20%20%20%20%20%20%20If%20IsError(n)%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20c%20%3D%20c%20%2B%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20ReDim%20Preserve%20y(1%20To%20UBound(x%2C%201)%20*%20UBound(x%2C%202)%2C%201%20To%20c)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20If%20IsError(m)%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20r%20%3D%20r%20%2B%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20y(r%2C%201)%20%3D%20x(i%20-%201%2C%201)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20y(r%2C%20c)%20%3D%20x(i%2C%20j)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Else%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20y(m%2C%20c)%20%3D%20x(i%2C%20j)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20y(1%2C%20c)%20%3D%20x(i%20-%201%2C%20j)%0A%20%20%20%20%20%20%20%20%20%20%20%20Else%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20If%20IsError(m)%20Then%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20r%20%3D%20r%20%2B%201%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20y(r%2C%20n)%20%3D%20x(i%2C%20j)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Else%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20y(m%2C%20n)%20%3D%20x(i%2C%20j)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20y(r%2C%201)%20%3D%20x(i%20-%201%2C%201)%0A%20%20%20%20%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20%20%20%20%20End%20If%0A%20%20%20%20Next%20j%0ANext%20i%0A%0ASet%20wsOutput%20%3D%20ThisWorkbook.Worksheets.Add(after%3A%3Drng.Parent)%0AwsOutput.Name%20%3D%20%22Output%22%0A%0AWith%20wsOutput.Range(%22A1%22).Resize(r%2C%20c)%0A%20%20%20%20.Value%20%3D%20y%0A%20%20%20%20.NumberFormat%20%3D%20%220.00%22%0A%20%20%20%20.Columns(1).AutoFit%0A%20%20%20%20.Borders.Color%20%3D%20vbBlack%0AEnd%20With%0A%0AApplication.DisplayAlerts%20%3D%20True%0AApplication.ScreenUpdating%20%3D%20True%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%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-830037%22%20slang%3D%22en-US%22%3ERe%3A%20How%20would%20I%20sort%2Ffilter%20this%20example%3F%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-830037%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F394231%22%20target%3D%22_blank%22%3E%40Subodh_Tiwari_sktneer%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20sir%20have%20saved%20the%20day%2C%20thank%20you%20very%20much!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-830569%22%20slang%3D%22en-US%22%3ERe%3A%20How%20would%20I%20sort%2Ffilter%20this%20example%3F%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-830569%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F365248%22%20target%3D%22_blank%22%3E%40nabilmourad%3C%2FA%3E%26nbsp%3BMaybe%20you%20can%20post%20the%20Power%20Query%20approach%3F%20That%20would%20help%20people%20who%20don't%20want%20to%20delve%20in%20to%20VBA.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-830600%22%20slang%3D%22en-US%22%3ERe%3A%20How%20would%20I%20sort%2Ffilter%20this%20example%3F%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-830600%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F377119%22%20target%3D%22_blank%22%3E%40Paneross%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou're%20welcome%20again!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-831127%22%20slang%3D%22en-US%22%3ERe%3A%20How%20would%20I%20sort%2Ffilter%20this%20example%3F%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-831127%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F7724%22%20target%3D%22_blank%22%3E%40Ingeborg%20Hawighorst%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIf%20with%20Power%20Query.%20To%20simplify%20I%20took%20the%20source%20as%20the%20table%2C%20not%20as%20named%20range.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20399px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F129342i4BF15ED1F8219AAF%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIn%20Power%20Query%20for%20the%20source%20table%20index%20every%20odd%2Feven%20row%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20786px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F129343i60430227A1167F4C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EWhen%20reference%20it%20and%2C%20if%20only%20main%20steps%2C%20filter%20only%20rows%20with%20codes%2C%20unpivot%20other%20than%20names%20columns%2C%20add%20index%2C%20after%20that%20sort%20by%20codes%20and%20names%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20326px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F129344iE1431D2BC516ECBD%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EAnother%20reference%20with%20exactly%20same%20steps%2C%20but%20here%20the%20only%20select%20numbers.%20Merge%20first%20reference%20with%20second%20one%20on%20index%2C%20extract%20numbers%20only%20from%20column%20with%20tables%20from%20second%20reference.%20It%20looks%20like%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20338px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F129345iFF555A5F2E65D5D1%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22image.png%22%20title%3D%22image.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EPivot%20it%20on%20codes%20for%20Value.1%20without%20aggregation%20and%20load%20result%20into%20Excel.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWith%20some%20coding%20that%20could%20be%20done%20more%20compact%20and%20combined%20in%20one%20query%2C%20but%20I%20tried%20to%20use%20UI%20only.%3C%2FP%3E%0A%3CP%3EMore%20details%20are%20in%20attached%20file.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-831184%22%20slang%3D%22en-US%22%3ERe%3A%20How%20would%20I%20sort%2Ffilter%20this%20example%3F%20Excel%202016%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-831184%22%20slang%3D%22en-US%22%3E%3CP%3EGood%20one%20%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%3C%2FP%3E%3C%2FLINGO-BODY%3E
Paneross
Occasional Contributor

Excel Example.png

Hello guys, I'm in need of some excel expertise. I've attached a sample picture of what my current spreadsheet looks like.

 

What I'm trying to do:  I have multiple abbreviations with an amount under columns B through G. 

I'm trying to sort all the JACM/CLAM/WYAK/etc and the numbers below them into their own column,  and I'm having alot of trouble doing so. I want Column B to be all JACM, C to be all WYAK, etc but still be lined up on correct guys under row A.

 

Thanks, sorry for the confusing explanation

16 Replies

@Paneross The problem here is that you have entered data into a report structure, and on top of that used inconsistent column patterns. This data is now really hard to handle, and re-arranging it will be tedious and most likely, manual.

 

A far better data entry structure would be just three columns, i.e. name, type, and value. From such a flat table you can then easily build the desired report with the data arranged as you describe.

Solution

@Paneross 

 

I have used VBA approach to get the data in the desired format.

In the attached, click the button called "Transform Data" on Sheet1 to run the code. You will be prompted to select the range with data and the code will insert a new sheet called "Output" with the data in the desired format.

 

Sub TransformData()
Dim wsOutput    As Worksheet
Dim rng         As Range
Dim x           As Variant
Dim y()         As Variant
Dim i           As Long
Dim j           As Long
Dim r           As Long
Dim c           As Long
Dim n           As Variant

On Error Resume Next
Set rng = Application.InputBox("Please select the Range with Data.", Type:=8)

If rng Is Nothing Then
    MsgBox "You didn't select any Range.", vbExclamation
    Exit Sub
End If

Application.ScreenUpdating = False
Application.DisplayAlerts = False

ThisWorkbook.Worksheets("Output").Delete
On Error GoTo 0

x = rng.Value
ReDim y(1 To UBound(x, 1) * UBound(x, 2), 1 To 1)

r = 1
c = 1

For i = 1 To UBound(x, 1)
    For j = 2 To UBound(x, 2)
        If IsNumeric(x(i, j)) And x(i, j) > 0 Then
            n = Application.Match(x(i - 1, j), Application.Index(y, 1, 0), 0)
            If IsError(n) Then
                r = r + 1
                c = c + 1
                ReDim Preserve y(1 To UBound(x, 1) * UBound(x, 2), 1 To c)
                y(r, 1) = x(i - 1, 1)
                y(1, c) = x(i - 1, j)
                y(r, c) = x(i, j)
            Else
                r = r + 1
                y(r, 1) = x(i - 1, 1)
                y(r, n) = x(i, j)
                
            End If
        End If
    Next j
Next i
Set wsOutput = ThisWorkbook.Worksheets.Add(after:=rng.Parent)
wsOutput.Name = "Output"
With wsOutput.Range("A1").Resize(r, c)
    .Value = y
    .NumberFormat = "0.00"
    .Columns(1).AutoFit
    .Borders.Color = vbBlack
End With

Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

 

 

@Subodh_Tiwari_sktneer  that was exactly what I was looking for! Thank you so much, you don't realize how much this will help now and in the future. I truly appreciate it!

@Paneross 

This is an optimum situation for using Power Query, just few clicks.

Good luck

Nabil Mourad

@Paneross 

 

You're welcome! Glad it worked as desired!

@nabilmourad 

 


@nabilmourad wrote:

This is an optimum situation for using Power Query, just few clicks.

This is absolutely pointless to criticize the accepted solution instead of posting your own solution., that makes no sense.

Highlighted

@Subodh_Tiwari_sktneer  You've been a great help, would you mind helping with this last question then I think I'll be set for a very long time. Now that I got the data sorted using the code provided, I've noticed I have duplicates, (see example "Problem Table"), now I'm trying to merge multiple entries in Column A, with the B:M data into one row. I've tried merging, subtotaling, and played with a pivot table and wasn't able to merge the rows, and get rid of the duplicates. Thanks!Problem Table.pngEnd Goal.png

@Subodh_Tiwari_sktneer 

 

Can you show me where I criticized your solution?

I am reporting this comment as a rude comment.

 

@Subodh_Tiwari_sktneer Hello, our moderation team has reviewed this and seems like a misunderstanding. Offering different advice to what's been accepted is not the same as criticizing that previous advice. Check out our code of conduct if you have any questions. 

@Eric Starker 

Sorry Eric if I violated the code of conduct. Please accept my apologies.

@Paneross 

 

In that case, you may try this...

 

Sub TransformData()
Dim wsOutput    As Worksheet
Dim rng         As Range
Dim x           As Variant
Dim y()         As Variant
Dim i           As Long
Dim j           As Long
Dim r           As Long
Dim c           As Long
Dim n           As Variant
Dim m           As Variant

On Error Resume Next
Set rng = Application.InputBox("Please select the Range with Data.", Type:=8)

If rng Is Nothing Then
    MsgBox "You didn't select any Range.", vbExclamation
    Exit Sub
End If

Application.ScreenUpdating = False
Application.DisplayAlerts = False

ThisWorkbook.Worksheets("Output").Delete
On Error GoTo 0

x = rng.Value
ReDim y(1 To UBound(x, 1) * UBound(x, 2), 1 To 1)

r = 1
c = 1

For i = 1 To UBound(x, 1)
    For j = 2 To UBound(x, 2)
        If IsNumeric(x(i, j)) And x(i, j) > 0 Then
            If i > 1 Then m = Application.Match(x(i - 1, 1), Application.Index(y, 0, 1), 0)
            n = Application.Match(x(i - 1, j), Application.Index(y, 1, 0), 0)
            If IsError(n) Then
                c = c + 1
                ReDim Preserve y(1 To UBound(x, 1) * UBound(x, 2), 1 To c)
                If IsError(m) Then
                    r = r + 1
                    y(r, 1) = x(i - 1, 1)
                    y(r, c) = x(i, j)
                Else
                    y(m, c) = x(i, j)
                End If
                y(1, c) = x(i - 1, j)
            Else
                If IsError(m) Then
                    r = r + 1
                    y(r, n) = x(i, j)
                Else
                    y(m, n) = x(i, j)
                End If
                y(r, 1) = x(i - 1, 1)
            End If
        End If
    Next j
Next i

Set wsOutput = ThisWorkbook.Worksheets.Add(after:=rng.Parent)
wsOutput.Name = "Output"

With wsOutput.Range("A1").Resize(r, c)
    .Value = y
    .NumberFormat = "0.00"
    .Columns(1).AutoFit
    .Borders.Color = vbBlack
End With

Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

 

 

@Subodh_Tiwari_sktneer 

 

You sir have saved the day, thank you very much!

@nabilmourad Maybe you can post the Power Query approach? That would help people who don't want to delve in to VBA.

@Paneross 

You're welcome again!

@Ingeborg Hawighorst 

If with Power Query. To simplify I took the source as the table, not as named range.

image.png

In Power Query for the source table index every odd/even row

image.png

When reference it and, if only main steps, filter only rows with codes, unpivot other than names columns, add index, after that sort by codes and names

image.png

Another reference with exactly same steps, but here the only select numbers. Merge first reference with second one on index, extract numbers only from column with tables from second reference. It looks like

image.png

Pivot it on codes for Value.1 without aggregation and load result into Excel.

 

With some coding that could be done more compact and combined in one query, but I tried to use UI only.

More details are in attached file.

Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
46 Replies
flashing a white screen while open new tab
Deleted in Discussions on
14 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
Extentions Synchronization
Deleted in Discussions on
3 Replies
Security Community Webinars
Valon_Kolica in Security, Privacy & Compliance on
13 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
30 Replies