+ Reply to Thread
Results 1 to 5 of 5

Find the Position of a Character in Excel Cell

  1. #1
    Registered User
    Join Date
    10-02-2012
    Location
    Al Khobar, Saudi Arabia
    MS-Off Ver
    Excel 2010-2013
    Posts
    47

    Find the Position of a Character in Excel Cell

    I want a formula to do a LEFT(Text,3) function IF the FOURTH character in the cell is "." and IF it is not give LEFT(Text,4).

  2. #2
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Find the Position of a Character in Excel Cell

    Hi,

    first attempt


    Please Login or Register  to view this content.
    or (less "robust" approach)

    Please Login or Register  to view this content.
    Regards
    Last edited by canapone; 03-20-2017 at 04:47 AM.
    -----------------------------------------------------

    At Excelforum, you can say "Thank you!" by clicking the star icon ("Add Reputation") below the post.

    Please, mark your thread [SOLVED] if you received your answer.

  3. #3
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,210

    Re: Find the Position of a Character in Excel Cell

    =IF(MID(a1,4,1)=".",LEFT(a1,3),LEFT(a1,4))

  4. #4
    Registered User
    Join Date
    10-02-2012
    Location
    Al Khobar, Saudi Arabia
    MS-Off Ver
    Excel 2010-2013
    Posts
    47

    Re: Find the Position of a Character in Excel Cell

    Could you please explain me the logic behind the LEFT function which you first mentioned. It is working well.

  5. #5
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Find the Position of a Character in Excel Cell

    Hi

    the logic is more or less the same in all formulas

    LEFT needs a number: how many characters need to be returned from A2 starting from the left.

    In this formula

    =LEFT(A2,4-(MID(A2,4,1)="."))

    4 is first answer, but formula subtracts 1 if

    (MID(A2,4,1)=".") is TRUE

    -TRUE is equivalent to -1

    If there no "." at the 4th position in A2, MID returns FALSE (zero).

    ------
    Formula from Davsth ( Hi!)

    =IF(MID(a1,4,1)=".",LEFT(a1,3),LEFT(a1,4))

    If 4th character of A2 is "." (TRUE), formula must extract 3 characters from A2 from the left.

    If 4th character of A2 is not "." (FALSE), formula must extract 4 characters from A2 from the left.

    Forgive my poor English (and poor explanation too)

    Regards
    Last edited by canapone; 03-21-2017 at 03:08 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Find position of designated character in Cell
    By CAABYYC in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 03-21-2016, 05:50 PM
  2. [SOLVED] FIND function finds the position of a character wrong.
    By zanshin777 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-07-2016, 09:49 AM
  3. [SOLVED] find the character position in a string of the last occurrence of a nominated character
    By jmac1947 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-04-2014, 11:52 PM
  4. Find Position of a Character in a Cell
    By daviieejay in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 11-30-2013, 11:08 PM
  5. Replies: 4
    Last Post: 07-14-2012, 07:26 AM
  6. Replies: 2
    Last Post: 02-22-2007, 12:42 PM
  7. Find Character Position in String
    By SportsDave in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-21-2006, 04:49 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1