Hi.
How do I write a macro to extract the last two words of a cell?
Hi.
How do I write a macro to extract the last two words of a cell?
Try:
Please Login or Register to view this content.
let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source
If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE
Walking the tightrope between genius and eejit...
Thanks but how do I insert it in a code? You know, with sub and end sub. Let's use cell A1 as the active cell.
Depends what you're doing with the output. Tell me what you're trying to do.
Cell A1 has the sentence "Hi, how are you doing?"
How do I display in cell B2 "You doing?" extracting these last two words only?
*Please note that the sentence in Cell A1 can vary.
Enter that function from my earlier post into a standard module.
In B2, use formula:
Formula:Please Login or Register to view this content.
And just for fun (and because I hate fixing values into functions), here's a further function where you can specify the number of words to return:
Use as:Please Login or Register to view this content.
A B 1Hi, how are you doing? Hi, how are you doing? 2=last2words(A1) you doing? 3=lastxwords(A1,3) are you doing?
Wow thanks. I'm still new to VBA so how do I enter what you posted into a regular code that I can hit straight from the excel sheet?
As I said, just paste the function code into a standard module of your workbook, then that function (a UDF, or User Defined Function) is then available for you to use in the worksheets of that workbook.
Thanks OllyXLS, this is a major break though in my excel experience!
Best of luck to you;-)
Glad it's helped, and that you've learned something Thanks for the feedback!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks