Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
marlea
 
Posts: n/a
Default 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!


--
marlea
------------------------------------------------------------------------
marlea's Profile: http://www.excelforum.com/member.php...o&userid=26209
View this thread: http://www.excelforum.com/showthread...hreadid=473524

  #2   Report Post  
B. R.Ramachandran
 
Posts: n/a
Default


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


  #3   Report Post  
swatsp0p
 
Posts: n/a
Default


Try this:

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

Does this work for you?


--
swatsp0p


------------------------------------------------------------------------
swatsp0p's Profile: http://www.excelforum.com/member.php...o&userid=15101
View this thread: http://www.excelforum.com/showthread...hreadid=473524

  #4   Report Post  
Myrna Larson
 
Posts: n/a
Default

=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
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   Report Post  
marlea
 
Posts: n/a
Default


Ah, I see, I was supposed to use REPLACE with FIND. Thank you so much!
This is perfect!

swatsp0p Wrote:
Try this:

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

Does this work for you?



--
marlea
------------------------------------------------------------------------
marlea's Profile: http://www.excelforum.com/member.php...o&userid=26209
View this thread: http://www.excelforum.com/showthread...hreadid=473524

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace nth place with colon marlea Excel Worksheet Functions 1 October 5th 05 08:48 PM
find position of a number in a string fullers80 Excel Worksheet Functions 1 September 6th 05 03:47 PM
Search - replace NOT in formulas Michael Preminger Excel Worksheet Functions 1 February 18th 05 08:13 PM


All times are GMT +1. The time now is 09:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"