+ Reply to Thread
Results 1 to 7 of 7

If found character insert a comma after it

Hybrid View

  1. #1
    Registered User
    Join Date
    01-30-2014
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    16

    Post If found character insert a comma after it

    Hello all,

    I have the following data in a cell:

    55°66'77.88"N122°33'44.55"W

    I need to be able to change it to this:

    55°66'77.88"N,122°33'44.55"W

    (All GPS coords have Ns and Ws only).

    So, if it finds the letter 'N', then insert a comma after it.

    Same would apply for a cell with the following data in it:

    12.345678°-123.456789°

    The above should be displayed like this:

    12.345678°,-123.456789°

    Haven't been able to find the correct formula.

    The closest one I have found so far is this:

    =REPLACE(B2,FIND("N",B2),0,",")

    But, I'm not replacing anything with anything, AND, it places a comma BEFORE the 'N' instead of AFTER it.

    Thank you in advance.

    --Nelson.

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: If found character insert a comma after it

    One formula to do both:
    Formula: copy to clipboard
    =SUBSTITUTE(SUBSTITUTE(B2,"°","°,"),"N","N,")
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Registered User
    Join Date
    01-30-2014
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: If found character insert a comma after it

    Quote Originally Posted by OllyXLS View Post
    One formula to do both:
    Formula: copy to clipboard
    =SUBSTITUTE(SUBSTITUTE(B2,"°","°,"),"N","N,")
    Thank you OllyXLS.

    I'll use =SUBSTITUTE(B2,"N","N,") only in the case of Ns since yours will produce something like this:

    36°,49'38.12"N,119°,33'36.40"W

    Other than that that works out perfectly. Simple enough I would say!

    Now, how about the other scenario where there's only degrees:

    12.345678°-123.456789°

    If I use =SUBSTITUTE(B4,"°","°,") then it will show the following:

    12.345678°,-123.456789°, (no comma needed at the end).


    Thank you again.

    --Nelson.

  4. #4
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: If found character insert a comma after it

    How about
    Formula: copy to clipboard
    =LEFT(SUBSTITUTE(B4,"°","°,"),LEN(B4)+1)

  5. #5
    Registered User
    Join Date
    01-30-2014
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: If found character insert a comma after it

    Quote Originally Posted by OllyXLS View Post
    How about
    Formula: copy to clipboard
    =LEFT(SUBSTITUTE(B4,"°","°,"),LEN(B4)+1)
    Awesome OllyXLS. Thank you very much.

    --Nelson.

  6. #6
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: If found character insert a comma after it

    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  7. #7
    Registered User
    Join Date
    01-30-2014
    Location
    California
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: If found character insert a comma after it

    Quote Originally Posted by arlu1201 View Post
    Based on your last post in this thread, its apparent that you are satisfied with the solution(s) you've received and have solved your question, but you haven't marked your thread as "SOLVED". I will do it for you this time.

    In future, to mark your thread as Solved, you can do the following -
    Select Thread Tools-> Mark thread as Solved.

    Incase your issue is not solved, you can undo it as follows -
    Select Thread Tools-> Mark thread as Unsolved.

    Also, since you are relatively new to the forum, i would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post which helped you. This adds to the reputation of the person who has taken the time to help you.
    Ok. Thank you.

    --Nelson.

+ 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. [SOLVED] Remove the first character only if it is a comma
    By Pearlyn in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 04-02-2013, 10:17 AM
  2. Replies: 3
    Last Post: 11-08-2012, 05:01 PM
  3. [SOLVED] If comma present, then place a character before and after comma (FORMULA)
    By jaimealvarez in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-21-2012, 04:04 PM
  4. Comma Showing Odd Character
    By ryanb4614 in forum Excel General
    Replies: 4
    Last Post: 07-31-2010, 12:58 AM
  5. How Remove Comma in the first character
    By antoni in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-23-2009, 01:31 AM

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