+ Reply to Thread
Results 1 to 5 of 5

Find nth occurrence and replace with ":"

  1. #1
    Registered User
    Join Date
    08-11-2005
    Posts
    24

    Find nth occurrence and replace with ":"

    I am altering REPLACE functions for different parts of my data. This works OK, but it would be more efficient if I could apply one function to all of my data.

    Data:
    Column A
    R1 volume measured by...
    R4 mass times...
    R11 weight is related...
    R12 height
    R100 distance and time
    R124 force

    I want to place a colon after the numbers; e.g., R1: volume...; R12: height. If I knew how to find the first occurrence of a space, I think I could just find those spaces and replace them with a colon and a space. My work-around is to use REPLACE this way:

    I apply this formula to cells with one-digit numbers:
    =REPLACE(A1, 3, 1, ": ")

    Then I slightly change the formula for cells with two-digit numbers:
    =REPLACE(A1, 4, 1, ": ") ... and so on.

    Can someone show me a better way of doing this? Thank you!

  2. #2
    Forum Expert swatsp0p's Avatar
    Join Date
    10-07-2004
    Location
    Kentucky, USA
    MS-Off Ver
    Excel 2010
    Posts
    1,545
    Try this:

    =REPLACE(A1,FIND(" ",A1,1),1,": ")

    Does this work for you?
    Bruce
    The older I get, the better I used to be.
    USA

  3. #3
    B. R.Ramachandran
    Guest

    RE: Find nth occurrence and replace with ":"


    Hi,

    Use,
    =REPLACE(A1,FIND(" ",A1),1,": ")

    Regards,
    B. R. Ramachandran


    "marlea" wrote:

    >
    > I am altering REPLACE functions for different parts of my data. This
    > works OK, but it would be more efficient if I could apply one function
    > to all of my data.
    >
    > Data:
    > Column A
    > R1 volume measured by...
    > R4 mass times...
    > R11 weight is related...
    > R12 height
    > R100 distance and time
    > R124 force
    >
    > I want to place a colon after the numbers; e.g., R1: volume...; R12:
    > height. If I knew how to find the first occurrence of a space, I think
    > I could just find those spaces and replace them with a colon and a
    > space. My work-around is to use REPLACE this way:
    >
    > I apply this formula to cells with one-digit numbers:
    > =REPLACE(A1, 3, 1, ": ")
    >
    > Then I slightly change the formula for cells with two-digit numbers:
    > =REPLACE(A1, 4, 1, ": ") ... and so on.
    >
    > Can someone show me a better way of doing this? Thank you!
    >
    >
    > --
    > marlea
    > ------------------------------------------------------------------------
    > marlea's Profile: http://www.excelforum.com/member.php...o&userid=26209
    > View this thread: http://www.excelforum.com/showthread...hreadid=473524
    >
    >


  4. #4
    Myrna Larson
    Guest

    Re: Find nth occurrence and replace with ":"

    =SUBSTITUTE(A1," ",": ")

    should work for numbers of any length and replace all spaces with colon and
    space.


    On Wed, 5 Oct 2005 13:54:07 -0500, marlea
    <[email protected]> wrote:

    >
    >I am altering REPLACE functions for different parts of my data. This
    >works OK, but it would be more efficient if I could apply one function
    >to all of my data.
    >
    >Data:
    >Column A
    >R1 volume measured by...
    >R4 mass times...
    >R11 weight is related...
    >R12 height
    >R100 distance and time
    >R124 force
    >
    >I want to place a colon after the numbers; e.g., R1: volume...; R12:
    >height. If I knew how to find the first occurrence of a space, I think
    >I could just find those spaces and replace them with a colon and a
    >space. My work-around is to use REPLACE this way:
    >
    >I apply this formula to cells with one-digit numbers:
    >=REPLACE(A1, 3, 1, ": ")
    >
    >Then I slightly change the formula for cells with two-digit numbers:
    >=REPLACE(A1, 4, 1, ": ") ... and so on.
    >
    >Can someone show me a better way of doing this? Thank you!


  5. #5
    Registered User
    Join Date
    08-11-2005
    Posts
    24
    Ah, I see, I was supposed to use REPLACE with FIND. Thank you so much! This is perfect!

    Quote Originally Posted by swatsp0p
    Try this:

    =REPLACE(A1,FIND(" ",A1,1),1,": ")

    Does this work for you?

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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