hatman
Well-known Member
- Joined
- Apr 8, 2005
- Messages
- 2,664
As some of you may have figured out, I am a little bit of a nut when it comes to the english language... in High School I was dubbed a "Walking Lexicon", and rather than being offended, I took it as a compliment.
Anyway, my latest fascination has been with Palindromes formed of multiple words: A Man, A Plan, A Canal, Panama for example. I mean, we all know about Radar, Rotor, and Rotator, but multiple word palindromes are little bit more challengeing. As I started thinking about it, I started wondering if one couldn't write a simple Array formula to invert the order of a text string. As I started playing with it, I also saw potential uses in other applications, but I would need to solve this one first.
I came up with a solution, but it requires the use of a function having the ability to concatenate an ARRAY of values, rather than the CSV list that Concatenate() requires. This solution is fine for me, as I wrote such a UDF years ago (and doesn't MoreFunc have one too?), but I would still like to know if this is possible in a single formula using nothing but native standard Excel functions. I would like the the scheme to more easily be shared with people who do NOT have an addin containing an improved concatenation function.
Here is the CSE formula that I came up with: =Concat(MID(A1,LEN(A1)+1-ROW(INDIRECT("1:"&LEN(A1))),1)) where concat is defined as
Can anyone come up with somethng better?
Anyway, my latest fascination has been with Palindromes formed of multiple words: A Man, A Plan, A Canal, Panama for example. I mean, we all know about Radar, Rotor, and Rotator, but multiple word palindromes are little bit more challengeing. As I started thinking about it, I started wondering if one couldn't write a simple Array formula to invert the order of a text string. As I started playing with it, I also saw potential uses in other applications, but I would need to solve this one first.
I came up with a solution, but it requires the use of a function having the ability to concatenate an ARRAY of values, rather than the CSV list that Concatenate() requires. This solution is fine for me, as I wrote such a UDF years ago (and doesn't MoreFunc have one too?), but I would still like to know if this is possible in a single formula using nothing but native standard Excel functions. I would like the the scheme to more easily be shared with people who do NOT have an addin containing an improved concatenation function.
Here is the CSE formula that I came up with: =Concat(MID(A1,LEN(A1)+1-ROW(INDIRECT("1:"&LEN(A1))),1)) where concat is defined as
Code:
Function concat(rnge, Optional delim As String = "") As String
For Each Item In rnge
If Item <> "" Then
Output = Output & delim & Item
End If
Next Item
concat = Right(Output, Len(Output) - Len(delim))
End Function
Can anyone come up with somethng better?