I have text strings like 12M5R. I need to add those numbers together regardless of how the text string is composed (there is alot of variation).
Thanks for any assistance![]()
I have text strings like 12M5R. I need to add those numbers together regardless of how the text string is composed (there is alot of variation).
Thanks for any assistance![]()
Hi Leif... 1+2+5=8 or 12+5=17?
12+5=17 Sorry for not making that clear
Is there any way to do this? or do I have to do manually?
Sorry Leif,
I meant to write back, but I was struggling with the VBA function (not my forte)... but I think I figured it out...
Again, my coding is far from "textbook"... I only learned VBA from trial and error... anyway, check out the function that I created... see if you can use it...
Contact me if you don't know how to copy the VBA in your worksheet...
Thanks,
Dennis
Re-post: I couldn't figure out a nice formula, so I decided on using VBA... anyone how has any other ideas or improvements or a more proper way to code it, is more than welcome... I like learning on how to do it more "properly"... thanks!
Last edited by djapigo; 12-03-2012 at 05:06 PM.
Try this Lief
_____________![]()
Please Login or Register to view this content.
aelgadi
>>> If I helped, Don't forget to add to my reputation (click on the at left bottom of the post)
>>> If satisfied with a solution, don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Hi aelgadi,
See post #3...
I see djapigo,
How about this
_________________________![]()
Please Login or Register to view this content.
aelgadi
>>> If I helped, Don't forget to add to my reputation (click on the at left bottom of the post)
>>> If satisfied with a solution, don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Nicely done, aelgadi... your code works great and shows a flaw in my declarations... should change Double and Integer to Long...
Nice work!
Or maybe
In Excel![]()
Please Login or Register to view this content.
Formula:
Please Login or Register to view this content.
Can you have decimal numbers in the string?
If so what would you expect from this
1.2M5R = 1.7, or 8?
If you need any more information, please feel free to ask.
However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....
Also
اس کی مدد کرتا ہے اگر
شکریہ کہنے کے لئے سٹار کلک کریں
If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.
Nice work Morcol but what happen if there is already space in original text string i.e 12M 3Y2 or consecutive letters i.e 12MUL34M
___________________
aelgadi
>>> If I helped, Don't forget to add to my reputation (click on the star at left bottom of the post)
>>> If satisfied with a solution, don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Last edited by aelgadi; 12-03-2012 at 11:03 PM.
Thanks djapigo. By the way, still you can use integers djapigo and thanks again
_____________________________________
aelgadi
>>> If I helped, Don't forget to add to my reputation (click on the star at left bottom of the post)
>>> If satisfied with a solution, don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
Last edited by aelgadi; 12-03-2012 at 11:03 PM.
Marcol ,
Tody I had a chance to test your codes and it works like a charm
a big star from me
____________________
aelgadi
>>> If I helped, Don't forget to add to my reputation (click on the star at left bottom of the post)
>>> If satisfied with a solution, don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
By replacing all non digits with a space we get a string with any number of spaces, some in groups, others as singletons.
Worksheetfunction.Trim() removes all redundant spaces, leading, trailing, and internally. we can now replace the spaces with "+"
If you use the VBa function Trim() only leading and trailing spaces are removed, then you'll possibly get multiple consecutive "+"s when you replace the spaces. In that case Evaluate() will fail.
I see Marcol thanks.
I used marcol's, it worked very well. Thank you guys/gals.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks