Solved

Function or formula to identify the last repeated character in a cell in Excell

Posted on 2016-10-24
9
37 Views
Last Modified: 2016-10-24
We have a list of files in an excel and want to separate their file extension.  We are using a combination of commands like search(), len(), left(), right().  However some files has various periods in their name (for example, file.of.mine.txt), thus making it difficult to set the 3 character of the extension.  So we thought if we can identify the last period we can calculate the exact 3 or 2 or 5 extension that a file may have (for example, filename.text or filename.manifext).

please advice.
0
Comment
Question by:rayluvs
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
You can use instrrev() to find the last instance of a char/string within a target string.
Example:
strFilename = "file.of.mine.txt"
strBasename = Left(strFilename, Instrrev(strFilename, ".") -1)
strExtension = Mid(strFilename, Instrrev(strFilename, ".") +1)

Open in new window


Note: You can also get this information with a FileSystemObject
0
 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
strExtension = Split("file.of.mine.txt", ".")(UBound(Split("file.of.mine.txt", ".")))
0
 
LVL 48

Accepted Solution

by:
Rgonzo1971 earned 500 total points
Comment Utility
Hi,

pls try as a formula
=RIGHT(A1,LEN(A1)-SEARCH("@",SUBSTITUTE(A1,".","@",LEN(A1)-LEN(SUBSTITUTE(A1,".","")))))

Open in new window

Regards
0
 

Author Comment

by:rayluvs
Comment Utility
The formula worked excellently separating the extension, but how do modify the formula to identify the last repeated period (".")?
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 45

Expert Comment

by:Martin Liss
Comment Utility
I don't understand. What do you mean by "identify"?
0
 

Author Comment

by:rayluvs
Comment Utility
example,

in file.of.mine.txt, the last "." is in the 13 position.  We want to identify the last ".".
0
 
LVL 45

Expert Comment

by:aikimark
Comment Utility
@rayluvs

Have you tested the other comments?
0
 
LVL 48

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 500 total points
Comment Utility
If you want the position of the last .
=SEARCH("@",SUBSTITUTE(A1,".","@",LEN(A1)-LEN(SUBSTITUTE(A1,".",""))))

Open in new window

0
 

Author Comment

by:rayluvs
Comment Utility
The other comments don't work in the cell, we want work directly on Excel cell.

Thanx Rg worked!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

What is a Form List Box? (skip if you know this) The forms List Box is the alternative to the ActiveX list box. If you are using excel 2007, you first make sure you have a developer tab (click the Orb)->"Excel Options"->Popular->"Show Developer tab…
Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now