Extract First Letters of each word in a String with VB, and then move onto the next string- Finally combine all letters with hyphens
Posted on 2007-10-11
I want to figure out a way using VB to extract the first letter in each individual word of a few different strings, and then combine them with hyphens in between each one. Basically, I'm trying to create unique identifiers for short sentences, that I can repeat based on the same sentence in the future.
If i have 3 strings that are on the same row in separate columns (1-2-3), and then
1.) "The Dog"
2.) "Ran Across"
3.) "The Yard"
I'd like for the end result of be "TD-RA-TY"
Another variable that will only exist on certain rows will be a numeric with a metric (example: 40YD) that i'd like to append to the end (TD-RA-TY-40YD). So there would have to be some sort of exception that said basically IF the 4th column is blank, do nothing, if not, insert a hyphen along with the entirety of the 4th column.
This will be repeated for a few hundred rows of excel data. Excel formula's aren't advanced enough to do this, and Vb is the only thing I can think of that might be able to help. I can also work with MS SQL server 2005 & Access.