Those with the courage to explore the weave and structure of the Cosmos, even where it differs profoundly from their wishes and prejudices, will penetrate its deepest mysteries.
Let's say I have "costco purchase 321.10" in A1, "Gym membership 20.10" in A2, "Mcdonalds .99" in A3, "payment 2289.20" in A4, and other similar items from A5 to A99, how can I split this information into 2 columns with the description in one column and the amount in the next? Since the number of characters for the description and amounts vary from cell to cell and some have more spaces than others, I don't think I can use Text To Column or split the cells by length or delimiter (these were the only methods I can think of). Please help! I don't want to have to do this manually! Answer from Richard Rost:
Yes, I'm sure it could be done, but you're probably going to have to use some VB code to write a custom function.
I would make a loop that would start at the end of the string and count backwards until it hits the first SPACE character. That would indicate where the description ends and the price begins. Now you know where you can split the cell into two.
You could also use a variety of VBA functions (like InstrRev) to find that space character.
A quick Google search shows me that there are a couple of CRAZY methods to do the same thing using non-VBA means. I searched for "excel search backwards" and found a couple.
So the answer to your question is "YES, it's certainly possible." Walking you through it, step by step, however, would take me a while. I hope this gives you some direction, however. Good luck.
Sorry, only students may add comments.
Click here for more
information on how you can set up an account.
If you are a Visitor, go ahead and post your reply as a
new comment, and we'll move it here for you
once it's approved. Be sure to use the same name and email address.
This thread is now CLOSED. If you wish to comment, start a NEW discussion in
Excel Forum.