close

how do i find palindromes using excel?

Find where? Are you asking if you can test if a string is a palindrome?
Or do you want to reverse a number, if the latter with the number in A1 use

=SUMPRODUCT(--(MID(A1,ROW(INDIRECT(quot;1:quot;amp;LEN(A1))),1))*10^(ROW(IN DIRECT(quot;1:quot;amp;
LEN(A1)))-1))

--

Regards,

Peo Sjoblomquot;yanquot; gt; wrote in message
...
gt; how do i find palindromes using excel?
Hi,

This is an absolutely inelegant solution to your post, but see whether it
works for you (Excel experts would laugh at this formula)!

To check whether a given string (upto 16 characters) contained in cell A1 is
a palindrome use the following formula:

=A1=MID(A1,16,1)amp;MID(A1,15,1)amp;MID(A1,14,1)amp;MID(A1, 13,1)amp;MID(A1,12,1)amp;MID(A1,11,1)amp;MID(A1,10,1)amp;MID(A 1,9,1)amp;MID(A1,8,1)amp;MID(A1,7,1)amp;MID(A1,6,1)amp;MID(A1, 5,1)amp;MID(A1,4,1)amp;MID(A1,3,1)amp;MID(A1,2,1)amp;MID(A1,1, 1)

If the string is a palindrome the formula returns quot;TRUEquot;, else quot;FALSEquot;.
Note that the formula doesn't differentiate upper and lower cases. If the
string is a number, start with a ' character.

To reverse a string (upto 16 characters),
remove the quot;=A1quot; at the beginning of the formula.

Regards,
B. R. Ramachandran

quot;yanquot; wrote:

gt; how do i find palindromes using excel?

Using VBA

Function Palindrome(strTest As String) As Boolean
Palindrome = Trim(strTest) = StrReverse(Trim(strTest))
End Function

See Chip Pearson's site for guidance on where to place the function's code
www.cpearson.com/excel/codemods.htm

Once you've got the code in the right place, utilize it like so:

with the word or phrase you want test in A1, put

=Palindrome(A1)

in B1. If it's a palindrome you'll see TRUE, otherwise FALSEquot;yanquot; wrote:

gt; how do i find palindromes using excel?

On Fri, 13 Jan 2006 07:50:02 -0800, yan gt; wrote:

gt;how do i find palindromes using excel?

Here's one way:

Download and install Longre's free morefunc.xll add-in from
xcell05.free.fr

With your test string in A1, the following formula will show TRUE if it is a
palindrome, and FALSE if it is not.

I assumed that you did NOT want to include punctuation, so that a string like:

quot;Madam, I'm Adamquot;

would test as true.

=REGEX.SUBSTITUTE(A1,quot;\Wquot;)=TEXTREVERSE(REGEX.SUBST ITUTE(A1,quot;\Wquot;))

This will also work with numeric input. However, if the number being tested
has one or more leading zeros, it will have to be entered as TEXT.--ron

On Fri, 13 Jan 2006 11:14:03 -0800, quot;Duke Careyquot;
gt; wrote:

gt;Using VBA
gt;
gt;Function Palindrome(strTest As String) As Boolean
gt; Palindrome = Trim(strTest) = StrReverse(Trim(strTest))
gt;End Function
gt;
gt;See Chip Pearson's site for guidance on where to place the function's code
gt;www.cpearson.com/excel/codemods.htm
gt;
gt;Once you've got the code in the right place, utilize it like so:
gt;
gt;with the word or phrase you want test in A1, put
gt;
gt;=Palindrome(A1)
gt;
gt;in B1. If it's a palindrome you'll see TRUE, otherwise FALSE
gt;
gt;
gt;quot;yanquot; wrote:
gt;
gt;gt; how do i find palindromes using excel?It might be preferable to ignore punctuation and case as well as spaces.

Perhaps:

===================================
Function Palindrome(StrTest As String) As Boolean
Dim temp As String
Dim i As Long

For i = 1 To Len(StrTest)
If Mid(StrTest, i, 1) Like quot;[0-9A-Za-z]quot; Then
temp = temp amp; UCase(Mid(StrTest, i, 1))
End If
Next i

Palindrome = temp = StrReverse(temp)

End Function
==========================--ron

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()