Solved

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

Posted on 2016-10-24
9
75 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 46

Expert Comment

by:aikimark
ID: 41857134
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 48

Expert Comment

by:Martin Liss
ID: 41857181
strExtension = Split("file.of.mine.txt", ".")(UBound(Split("file.of.mine.txt", ".")))
0
 
LVL 52

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41857192
Hi,

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

Open in new window

Regards
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

Author Comment

by:rayluvs
ID: 41857240
The formula worked excellently separating the extension, but how do modify the formula to identify the last repeated period (".")?
0
 
LVL 48

Expert Comment

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

Author Comment

by:rayluvs
ID: 41857256
example,

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

Expert Comment

by:aikimark
ID: 41857263
@rayluvs

Have you tested the other comments?
0
 
LVL 52

Assisted Solution

by:Rgonzo1971
Rgonzo1971 earned 500 total points
ID: 41857278
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
ID: 41857289
The other comments don't work in the cell, we want work directly on Excel cell.

Thanx Rg worked!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

622 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