keith05281967
Board Regular
- Joined
- May 6, 2011
- Messages
- 68
Greetings,
I've got some text strings that I'm trying to format in VBA.
An example would be changing this:
"San Diego CA" to this "SAN DIEGO, CA"
"Houston TX" to this "HOUSTON, TX"
So, regardless how many spaces are between the city state, and yes it varies, I want it to be formatted to city-comma-one space-state like the above example.
The below code is close to what i'm looking for but it's but only close. It isn't intelligent enough to adjust with varying spacing.
Selection.Value = UCase(Selection.Value)
s = Cells(i, ColumnNumber1).Value
s = Trim(s)
s = Left(s, Len(s) - 9) & ", " & Right(s, 2)
I'm looking for a VBA solution, not a spreadsheet function. Any advice would be appreciated.
thank you,
Keith
I've got some text strings that I'm trying to format in VBA.
An example would be changing this:
"San Diego CA" to this "SAN DIEGO, CA"
"Houston TX" to this "HOUSTON, TX"
So, regardless how many spaces are between the city state, and yes it varies, I want it to be formatted to city-comma-one space-state like the above example.
The below code is close to what i'm looking for but it's but only close. It isn't intelligent enough to adjust with varying spacing.
Selection.Value = UCase(Selection.Value)
s = Cells(i, ColumnNumber1).Value
s = Trim(s)
s = Left(s, Len(s) - 9) & ", " & Right(s, 2)
I'm looking for a VBA solution, not a spreadsheet function. Any advice would be appreciated.
thank you,
Keith