Checking For Palindromes

mianmazher

Active Member
Joined
Jan 24, 2004
Messages
412
Hi all forum Members

I want a formula to check for a number or text whether it is a palindrome
if in cell A1 I have 111 in B1 Its should say Its a aplindrome

similarlty for aba in cell A1

if I have 1111111233 in cell A1 in B1 I want a formula to say Its not Palindrome

Regards

Mian Mazher
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Here you are:

Code:
Function Palindrome(x) As Variant
    Dim y As String
    y = StrReverse(CStr(x))
    If y = CStr(x) Then
        Palindrome = "Palindrome"
    Else
        Palindrome = "Not a Palindrome"
    End If
End Function
 
Upvote 0
Hi Sir Aladin


I modified this formula

=IF(AND(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)=MID(A1,LEN(A1)+1-ROW(INDIRECT("1:"&LEN(A1))),1)),"Palindrome", "Try Again")


and entered without Ctrl+Shift+Enter


and its still working


U told to enter as array

Any difference between two?



Regards

Mian Mazher
 
Upvote 0
mianmazher said:
...


I modified this formula

=IF(AND(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)=MID(A1,LEN(A1)+1-ROW(INDIRECT("1:"&LEN(A1))),1)),"Palindrome", "Try Again")

In order to be able to say "Palindrome" or "Try Again"?

and entered without Ctrl+Shift+Enter


and its still working...

It still needs confirming with control+shift+enter. Try

xxxmmnnxxx

as input in A1.

If you'd like to see "Palindrome" and "Try Again" instead of TRUE and FALSE, here is a shorter way:

Just put -- before the original formula, that is:

=--AND(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)=MID(A1,LEN(A1)+1-ROW(INDIRECT("1:"&LEN(A1))),1))

and confirm with control+shift+enter.

Now custom format the formula cell as:

[=1]"Palindrome";[=0]"Try Again"
 
Upvote 0

Forum statistics

Threads
1,223,932
Messages
6,175,468
Members
452,646
Latest member
tudou

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top