Formula to retrieve characters from a cell

Abgar

Active Member
Joined
Jun 20, 2009
Messages
265
Hi guys,

Looking for a formula that will find the last occurrence of a character in a cell, and then show that character, plus 3 characters before and after.

In the example below, i am looking for the occurance of a colon ( : ) in A1 and showing the 3 characters before and after, to return the contents of cell B1. (i.e. - the formula goes in B1 and returns the value)

<table style="font-family:Calibri,Arial; font-size:11pt; background-color:#ffffff; padding-left:2pt; padding-right:2pt; " border="1" cellpadding="0" cellspacing="0"> <colgroup><col style="font-weight:bold; width:30px; "><col style="width:192px;"><col style="width:58px;"></colgroup><tbody><tr style="background-color:#cacaca; text-align:center; font-weight:bold; font-size:8pt; "><td>
</td><td>A</td><td>B</td></tr><tr style="height:18px ;"><td style="font-size:8pt; background-color:#cacaca; text-align:center; ">1
</td><td>01a887nno123:987thnpx120</td><td>123:987</td></tr></tbody></table>
There "shouldn't" be any cells that contain 2 colons in the same text, but just on the chance that there are, it will always be the last occurance (the righthand most one) that i would need to return.

Can this be done in a simple formula?

Thanks so much for your help as always :)
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Try this
Excel Workbook
AB
101a887nno123:987thnpx120123:987
201a887nno123:987thnpx:120npx:120
Sheet1
Excel 2003
Cell Formulas
RangeFormula
B1=MID(A1,SEARCH(CHAR(10),SUBSTITUTE(A1,":",CHAR(10),LEN(A1)-LEN(SUBSTITUTE(A1,":",""))))-3,7)
 
Upvote 0

Forum statistics

Threads
1,224,598
Messages
6,179,823
Members
452,946
Latest member
JoseDavid

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