SOLVED

Formula to extract only numbers from the end of a string until occurrence of alphabet or /

%3CLINGO-SUB%20id%3D%22lingo-sub-1523432%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20to%20extract%20only%20numbers%20from%20the%20end%20of%20a%20string%20until%20occurrence%20of%20alphabet%20or%20%2F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1523432%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F724985%22%20target%3D%22_blank%22%3E%40rmghosh%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAre%20numbers%20you%20trying%20to%20extract%20always%20two%20digit%20numbers%3F%3C%2FP%3E%3CP%3ECan%20you%20provide%20more%20such%20samples%20with%20the%20desired%20output%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1523440%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20to%20extract%20only%20numbers%20from%20the%20end%20of%20a%20string%20until%20occurrence%20of%20alphabet%20or%20%2F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1523440%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F724985%22%20target%3D%22_blank%22%3E%40rmghosh%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhat%20you're%20trying%20to%20do%20is%20not%20so%20easy%20to%20do%20with%20an%20Excel%20formula%2C%20but%20it%20is%20somewhat%20trivial%20to%20do%20in%20Power%20Query.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20process%20summary%20is%20as%20follows%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3COL%3E%3CLI%3ECreate%20a%20query%20on%20the%20data%20you%20want%20to%20split%20the%20number%20from%3C%2FLI%3E%3CLI%3ECreate%20a%20new%20column%20that%20reverses%20the%20data%20you%20want%20to%20split%3C%2FLI%3E%3CLI%3ESplit%20the%20new%20column%20on%20digit%20to%20non-digit%2C%20keeping%20only%20the%20first%20split%20item%3C%2FLI%3E%3CLI%3EReverse%20the%20item%20obtained%20in%20step%203%3C%2FLI%3E%3CLI%3ESplit%20step%204%20on%20digit%20to%20non-digit%2C%20again%20keeping%20only%20the%20first%20item%3C%2FLI%3E%3CLI%3EChange%20the%20data%20type%20of%20the%20result%20of%20Step%205%20to%20whole%20number%3C%2FLI%3E%3CLI%3EOptionally%20rename%20the%20output%20column%3C%2FLI%3E%3C%2FOL%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EStep%201%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPut%20your%20cursor%20anywhere%20in%20your%20list%20of%20data%20to%20transform%20and%20use%20Data%26gt%3BGet%20%26amp%3B%20Transform%20Data%26gt%3BFrom%20Table%2FRange.%20This%20will%20create%20a%20query%20on%20that%20dataset%20and%20open%20the%20Power%20Query%20Editor.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EStep%202%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUse%20Add%20Column%26gt%3BCustom%20Column%20with%20this%20formula%20(assuming%20your%20list%20of%20strings%20is%20in%20a%20column%20called%20data)%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3EText.Reverse(%5Bdata%5D)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECall%20the%20column%20%22Reversed%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EStep%203%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EUse%20Transform%26gt%3BSplit%20Column%26gt%3BBy%20Digit%20to%20Non-digit%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20will%20create%20a%20number%20of%20columns%20called%20Reversed.1%2C%20Reversed.2%2C%20etc.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESelect%20all%20of%20the%20created%20columns%20except%20the%20first%20one%20and%20right-click%20then%20Remove%20those%20columns.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAt%20this%20point%2C%20my%20working%20example%20looks%20like%20this%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22SplitReverse1.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%2F205456i70707BF81A4AA567%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22SplitReverse1.png%22%20alt%3D%22SplitReverse1.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CDIV%20class%3D%22mceNonEditable%20lia-copypaste-placeholder%22%3E%26nbsp%3B%3C%2FDIV%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EStep%204%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAgain%2C%20use%20Add%20Column%26gt%3BCustom%20Column%20and%20reverse%20the%20right-most%20column%20shown%20above%2C%20with%20this%20formula%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3EText.Reverse(%5BReversed.1%5D)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECall%20this%20column%20%22Reversed2%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EStep%205%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESelect%20Reversed2%20then%20use%20Transform%26gt%3BSplit%20By%26gt%3BDigit%20to%20Non-digit%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAt%20this%20point%2C%20you%20will%20have%20this%3A%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22SplitReverse2.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%2F205457iF5FB4CFD62E2E930%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22SplitReverse2.png%22%20alt%3D%22SplitReverse2.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20see%20that%20you%20have%20the%20right%20data%20in%20the%20column%20Reversed2.1%20above.%20Now%20a%20little%20cleanup.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERemove%20the%20columns%20you%20don't%20need%20by%20right-click%20remove.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EStep%206%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EClick%20the%20ABC%20icon%20at%20the%20top%20of%20the%20Reversed2.1%20column%20shown%20above%20and%20change%20the%20data%20type%20to%20Whole%20Number.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EStep%207%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERight%20click%20the%20Reversed2.1%20column%20and%20Rename%20it%20to%20something%20more%20sensible.%20I%20renamed%20mine%20to%20%22LastNumber%22.%20You%20can%20now%20use%20Home%26gt%3BClose%26amp%3BLoad%20to%20put%20the%20data%20back%20into%20the%20workbook.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20reference%2C%20here's%20the%20entire%20query%20from%20Home%26gt%3BAdvanced%20Editor%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powerquery%22%3E%3CCODE%3Elet%0A%20%20%20%20Source%20%3D%20Excel.CurrentWorkbook()%7B%5BName%3D%22Table1%22%5D%7D%5BContent%5D%2C%0A%20%20%20%20%23%22Changed%20Type%22%20%3D%20Table.TransformColumnTypes(Source%2C%7B%7B%22data%22%2C%20type%20text%7D%7D)%2C%0A%20%20%20%20%23%22Added%20Custom%22%20%3D%20Table.AddColumn(%23%22Changed%20Type%22%2C%20%22Reversed%22%2C%20each%20Text.Reverse(%5Bdata%5D))%2C%0A%20%20%20%20%23%22Split%20Column%20by%20Character%20Transition%22%20%3D%20Table.SplitColumn(%23%22Added%20Custom%22%2C%20%22Reversed%22%2C%20Splitter.SplitTextByCharacterTransition(%7B%220%22..%229%22%7D%2C%20(c)%20%3D%26gt%3B%20not%20List.Contains(%7B%220%22..%229%22%7D%2C%20c))%2C%20%7B%22Reversed.1%22%7D)%2C%0A%20%20%20%20%23%22Added%20Custom1%22%20%3D%20Table.AddColumn(%23%22Split%20Column%20by%20Character%20Transition%22%2C%20%22Reversed2%22%2C%20each%20Text.Reverse(%5BReversed.1%5D))%2C%0A%20%20%20%20%23%22Split%20Column%20by%20Character%20Transition1%22%20%3D%20Table.SplitColumn(%23%22Added%20Custom1%22%2C%20%22Reversed2%22%2C%20Splitter.SplitTextByCharacterTransition(%7B%220%22..%229%22%7D%2C%20(c)%20%3D%26gt%3B%20not%20List.Contains(%7B%220%22..%229%22%7D%2C%20c))%2C%20%7B%22Reversed2.1%22%2C%20%22Reversed2.2%22%7D)%2C%0A%20%20%20%20%23%22Removed%20Columns%22%20%3D%20Table.RemoveColumns(%23%22Split%20Column%20by%20Character%20Transition1%22%2C%7B%22Reversed2.2%22%2C%20%22Reversed.1%22%7D)%2C%0A%20%20%20%20%23%22Changed%20Type1%22%20%3D%20Table.TransformColumnTypes(%23%22Removed%20Columns%22%2C%7B%7B%22Reversed2.1%22%2C%20Int64.Type%7D%7D)%2C%0A%20%20%20%20%23%22Renamed%20Columns%22%20%3D%20Table.RenameColumns(%23%22Changed%20Type1%22%2C%7B%7B%22Reversed2.1%22%2C%20%22LastNumber%22%7D%7D)%0Ain%0A%20%20%20%20%23%22Renamed%20Columns%22%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EMy%20example%20workbook%20is%20attached%20here.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1523277%22%20slang%3D%22en-US%22%3EFormula%20to%20extract%20only%20numbers%20from%20the%20end%20of%20a%20string%20until%20occurrence%20of%20alphabet%20or%20%2F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1523277%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20am%20new%20to%20Excel.%20I%20want%20to%20build%20a%20formula%20on%20Excel%20which%20extracts%20only%20the%20numerical%20values%20from%20the%20end%20of%20the%20string%20until%20the%20occurrence%20of%20an%20alphabet%20or%20special%20character.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20example.%3C%2FP%3E%3CP%3EColumn%20A%20is%20the%20entry%20and%20Column%20B%20should%20be%20my%20result%20as%20I%20need%20this%20measure%20to%20join%20two%20files.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EA%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20B%3C%2FP%3E%3CP%3E%3CSPAN%3EABC%20132%2F4X32%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B32%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EUS%2C9%2F24FZ%2CXYZ%2FABC%20WIP%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B24%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EQWERT%204%2F2%20x%2024FZ%20AB%20AB%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B24%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EABC%20UYI%209%2F24FZ%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B24%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EABC%20UIOP%2010ML%2F9%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%209%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EABC%20YUIO%2012%2F8Z%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B8%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%3EPlease%20let%20me%20know%20if%20there%20is%20a%20formula%20to%20extract%20such%20a%20level%20of%20information.%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%3EAny%20help%20would%20be%20appreciated.%20Thank%20you%20in%20advance.%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1523277%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1523445%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20to%20extract%20only%20numbers%20from%20the%20end%20of%20a%20string%20until%20occurrence%20of%20alphabet%20or%20%2F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1523445%22%20slang%3D%22en-US%22%3E%3CP%3ENo%2C%20it%20could%20also%20be%20one%20digit!%3C%2FP%3E%3CP%3EI%20updated%20some%20more%20examples%20for%20your%20reference.%3C%2FP%3E%3CP%3EThank%20you.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1523473%22%20slang%3D%22de-DE%22%3ESubject%3A%20Formula%20to%20extract%20only%20numbers%20from%20the%20end%20of%20a%20string%20until%20occurrence%20of%20alphabet%20or%20%2F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1523473%22%20slang%3D%22de-DE%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F724985%22%20target%3D%22_blank%22%3E%40rmghosh%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22tlid-translation%20translation%22%3E%3CSPAN%20class%3D%22%22%3EMaybe%20these%20two%20formulas%20will%20help%20you.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22tlid-translation%20translation%22%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Text_Zahlen_trennen.JPG%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F205459i49F378F190F496DC%2Fimage-size%2Fmedium%3Fv%3D1.0%26amp%3Bpx%3D400%22%20title%3D%22Text_Zahlen_trennen.JPG%22%20alt%3D%22Numbers%20of%20Text%20Separation%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3ENumbers%20of%20Text%20Separation%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22tlid-translation%20translation%22%3E%3CSPAN%20class%3D%22%22%3ECopied%20freehand%20from%20the%20Internet%3C%2FSPAN%3E%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%3CBR%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EI%20would%20be%20happy%20to%20find%20out%20if%20I%20could%20help.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ENikolino%3C%2FP%3E%3CP%3EI%20know%20I%20don't%20know%20anything%20(Socrates)%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1523478%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20to%20extract%20only%20numbers%20from%20the%20end%20of%20a%20string%20until%20occurrence%20of%20alphabet%20or%20%2F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1523478%22%20slang%3D%22en-US%22%3EThis%20worked%20perfectly.%20Thank%20you%20so%20much!%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi All

 

I am new to Excel. I want to build a formula on Excel which extracts only the numerical values from the end of the string until the occurrence of an alphabet or special character.

 

For example.

Column A is the entry and Column B should be my result as I need this measure to join two files.

 

A                                                  B

ABC 132/4X32                             32

US,9/24FZ,XYZ/ABC WIP             24

QWERT 4/2 x 24FZ AB AB           24

ABC UYI 9/24FZ                           24

ABC UIOP 10ML/9                        9

ABC YUIO 12/8Z                           8

 

Please let me know if there is a formula to extract such a level of information.

Any help would be appreciated. Thank you in advance.

5 Replies
Highlighted

@rmghosh 

Are numbers you trying to extract always two digit numbers?

Can you provide more such samples with the desired output?

Highlighted
Best Response confirmed by rmghosh (New Contributor)
Solution

@rmghosh 

 

What you're trying to do is not so easy to do with an Excel formula, but it is somewhat trivial to do in Power Query.

 

The process summary is as follows:

 

  1. Create a query on the data you want to split the number from
  2. Create a new column that reverses the data you want to split
  3. Split the new column on digit to non-digit, keeping only the first split item
  4. Reverse the item obtained in step 3
  5. Split step 4 on digit to non-digit, again keeping only the first item
  6. Change the data type of the result of Step 5 to whole number
  7. Optionally rename the output column

 

Step 1

 

Put your cursor anywhere in your list of data to transform and use Data>Get & Transform Data>From Table/Range. This will create a query on that dataset and open the Power Query Editor.

 

 

Step 2

 

Use Add Column>Custom Column with this formula (assuming your list of strings is in a column called data):

 

 

Text.Reverse([data])

 

 

Call the column "Reversed"

 

 

Step 3

 

Use Transform>Split Column>By Digit to Non-digit

 

This will create a number of columns called Reversed.1, Reversed.2, etc.

 

Select all of the created columns except the first one and right-click then Remove those columns.

 

At this point, my working example looks like this:

SplitReverse1.png

 

 

Step 4

 

Again, use Add Column>Custom Column and reverse the right-most column shown above, with this formula:

 

 

Text.Reverse([Reversed.1])

 

 

Call this column "Reversed2".

 

 

Step 5

 

Select Reversed2 then use Transform>Split By>Digit to Non-digit

 

At this point, you will have this:

SplitReverse2.png

 

 

You can see that you have the right data in the column Reversed2.1 above. Now a little cleanup.

 

Remove the columns you don't need by right-click remove.

 

 

Step 6

 

Click the ABC icon at the top of the Reversed2.1 column shown above and change the data type to Whole Number.

 

 

Step 7

 

Right click the Reversed2.1 column and Rename it to something more sensible. I renamed mine to "LastNumber". You can now use Home>Close&Load to put the data back into the workbook.

 

 

For reference, here's the entire query from Home>Advanced Editor:

 

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"data", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Reversed", each Text.Reverse([data])),
    #"Split Column by Character Transition" = Table.SplitColumn(#"Added Custom", "Reversed", Splitter.SplitTextByCharacterTransition({"0".."9"}, (c) => not List.Contains({"0".."9"}, c)), {"Reversed.1"}),
    #"Added Custom1" = Table.AddColumn(#"Split Column by Character Transition", "Reversed2", each Text.Reverse([Reversed.1])),
    #"Split Column by Character Transition1" = Table.SplitColumn(#"Added Custom1", "Reversed2", Splitter.SplitTextByCharacterTransition({"0".."9"}, (c) => not List.Contains({"0".."9"}, c)), {"Reversed2.1", "Reversed2.2"}),
    #"Removed Columns" = Table.RemoveColumns(#"Split Column by Character Transition1",{"Reversed2.2", "Reversed.1"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Removed Columns",{{"Reversed2.1", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Reversed2.1", "LastNumber"}})
in
    #"Renamed Columns"

 

 

 

My example workbook is attached here.

Highlighted

No, it could also be one digit!

I updated some more examples for your reference.

Thank you.

Highlighted

@rmghosh 

 

Maybe these two formulas will help you.

Zahle von Text TrennenZahle von Text Trennen

Copied freehand from the Internet

I would be happy to find out if I could help.

 

Nikolino

I know I don't know anything (Socrates)

Highlighted
This worked perfectly. Thank you so much!