ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   how do i find palindromes using excel? (https://www.excelbanter.com/excel-worksheet-functions/65070-how-do-i-find-palindromes-using-excel.html)

yan

how do i find palindromes using excel?
 
how do i find palindromes using excel?

Peo Sjoblom

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("1:"&LEN(A1))),1))*10^(ROW(IN DIRECT("1:"&
LEN(A1)))-1))

--

Regards,

Peo Sjoblom


"yan" wrote in message
...
how do i find palindromes using excel?




B. R.Ramachandran

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)&MID(A1,15,1)&MID(A1,14,1)&MID(A1, 13,1)&MID(A1,12,1)&MID(A1,11,1)&MID(A1,10,1)&MID(A 1,9,1)&MID(A1,8,1)&MID(A1,7,1)&MID(A1,6,1)&MID(A1, 5,1)&MID(A1,4,1)&MID(A1,3,1)&MID(A1,2,1)&MID(A1,1, 1)

If the string is a palindrome the formula returns "TRUE", else "FALSE".
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 "=A1" at the beginning of the formula.

Regards,
B. R. Ramachandran

"yan" wrote:

how do i find palindromes using excel?


Duke Carey

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
http://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 FALSE


"yan" wrote:

how do i find palindromes using excel?


Ron Rosenfeld

how do i find palindromes using excel?
 
On Fri, 13 Jan 2006 07:50:02 -0800, yan wrote:

how do i find palindromes using excel?


Here's one way:

Download and install Longre's free morefunc.xll add-in from
http://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:

"Madam, I'm Adam"

would test as true.

=REGEX.SUBSTITUTE(A1,"\W")=TEXTREVERSE(REGEX.SUBST ITUTE(A1,"\W"))

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

Ron Rosenfeld

how do i find palindromes using excel?
 
On Fri, 13 Jan 2006 11:14:03 -0800, "Duke Carey"
wrote:

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
http://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 FALSE


"yan" wrote:

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 "[0-9A-Za-z]" Then
temp = temp & UCase(Mid(StrTest, i, 1))
End If
Next i

Palindrome = temp = StrReverse(temp)

End Function
==========================


--ron


All times are GMT +1. The time now is 12:02 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com