Unable use of regular expressions (RegEx) in Excel

%3CLINGO-SUB%20id%3D%22lingo-sub-3358085%22%20slang%3D%22en-US%22%3EUnable%20use%20of%20regular%20expressions%20(RegEx)%20in%20Excel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3358085%22%20slang%3D%22en-US%22%3E%3CP%3EI%20love%20function%20regex%20in%20R%20programming%20and%20want%20to%20use%20in%20excel%2C%20then%20I%20enable%20MS%20VB%20script%20as%20method%20in%20this%20clip.%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fyoutu.be%2FaLIVaUxSWgA%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fyoutu.be%2FaLIVaUxSWgA%3C%2FA%3E%26nbsp%3B%26nbsp%3BBut%20it%20not%20working%20%3Apensive_face%3A%3C%2FP%3E%3CP%3EI%20can't%20call%20this%20function%20via%20'%20%3Dregex%20'%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECould%20you%20please%20help%20on%20this%20issue%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%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%22Nhattha_0-1652280120389.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F370837i82B62B2DF74F276D%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Nhattha_0-1652280120389.png%22%20alt%3D%22Nhattha_0-1652280120389.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%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3358085%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-3358606%22%20slang%3D%22en-US%22%3ERe%3A%20Unable%20use%20of%20regular%20expressions%20(RegEx)%20in%20Excel%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3358606%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1387133%22%20target%3D%22_blank%22%3E%40Nhattha%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EYou%20cannot%20use%20Regex%20directly%20in%20a%20cell%20formula.%3C%2FP%3E%0A%3CP%3EInstead%2C%20you%20can%20use%20it%20in%20macros.%3C%2FP%3E%0A%3CP%3EYou%20can%20also%20use%20it%20in%20custom%20functions%20written%20in%20VBA.%20You%20can%20then%20use%20such%20a%20function%20in%20a%20cell%20formula.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ESee%20%3CA%20href%3D%22https%3A%2F%2Fstackoverflow.com%2Fquestions%2F19481175%2Fgeneral-purpose-udfs-for-using-regular-expressions-in-excel%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3EGeneral%20Purpose%20UDFs%20for%20using%20Regular%20Expressions%20in%20Excel%3C%2FA%3E%20for%20some%20examples%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

I love function regex in R programming and want to use in excel, then I enable MS VB script as method in this clip. https://youtu.be/aLIVaUxSWgA  But it not working

I can't call this function via ' =regex ' 

 

Could you please help on this issue?

 

Thank you

 

Nhattha_0-1652280120389.png

 

 

1 Reply

@Nhattha 

You cannot use Regex directly in a cell formula.

Instead, you can use it in macros.

You can also use it in custom functions written in VBA. You can then use such a function in a cell formula.

 

See General Purpose UDFs for using Regular Expressions in Excel for some examples