Find Last Character Position

kashif.special2005

Active Member
Joined
Oct 26, 2009
Messages
443
Hi,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>
How can I find last character position
<o:p> </o:p>
Kj34552 : last character position is 2
Tiwu45829 : last character position is 4
<o:p> </o:p>
I am using this array formula is giving me first character how can I find last character position
<o:p> </o:p>
MID(A5,ROW(INDIRECT("1:"&LEN(A5))),1)
<o:p> </o:p>
Please help
<o:p> </o:p>
Thanks,
Kashif.<o:p></o:p>
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Try this:
Array formula confirm CTRL+SHIFT+ENTER:
=LEN(SUBSTITUTE(A1,MID(A1,MATCH(TRUE,ISNUMBER(1*MID(A1,ROW($1:$9),1)),0),COUNT(1*MID(A1,ROW($1:$9),1))),""))
 
Upvote 0
Hi,
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>
How can I find last character position
<o:p></o:p>
Kj34552 : last character position is 2
Tiwu45829 : last character position is 4
<o:p></o:p>
I am using this array formula is giving me first character how can I find last character position
<o:p></o:p>
MID(A5,ROW(INDIRECT("1:"&LEN(A5))),1)
<o:p></o:p>
Please help
<o:p></o:p>
Thanks,
Kashif.<o:p></o:p>

Try...

=MIN(FIND({0,1,2,3,4,5,6,7,8,9},A2&"0123456789"))-1

assuming that the digits are always at the end of the string of interest.
 
Upvote 0
You can try the following User Defined Function for a VBA solution:

If your string is in A1, you can use =LastChar(A1) in your worksheet.

Code:
Function LastChar(str As String) As Integer
Dim FirstNumber As String
With CreateObject("VBScript.RegExp")
     .Pattern = "\d"
     FirstNumber = .Execute(str)(0)
End With
LastChar = Application.WorksheetFunction.Find(FirstNumber, str, 1) - 1
End Function
 
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,896
Members
452,948
Latest member
Dupuhini

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