Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Find position of a character within the worksheet cell

If you have a cell whose contents contain a sentence of text with several
spaces, how can you find the position of the last space?

Thanks in advance,

Christmas May
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Find position of a character within the worksheet cell

InstrRev() function. Perhaps I should read the help files before posting!

"Christmas May" wrote:

If you have a cell whose contents contain a sentence of text with several
spaces, how can you find the position of the last space?

Thanks in advance,

Christmas May

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Find position of a character within the worksheet cell

Try

=FIND(CHAR(1),SUBSTITUTE(A1," ",CHAR(1),LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))

As you posted in programming here's a VB solution

Lastspace = Len(Left(Range("A1"), InStrRev(Range("A1"), " ") - 1)) + 1

Mike

Mike

"Christmas May" wrote:

If you have a cell whose contents contain a sentence of text with several
spaces, how can you find the position of the last space?

Thanks in advance,

Christmas May

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default Find position of a character within the worksheet cell

Far too complicated

Lastspace = InStrRev(Range("A1"), " ")

Mike

"Mike H" wrote:

Try

=FIND(CHAR(1),SUBSTITUTE(A1," ",CHAR(1),LEN(A1)-LEN(SUBSTITUTE(A1," ",""))))

As you posted in programming here's a VB solution

Lastspace = Len(Left(Range("A1"), InStrRev(Range("A1"), " ") - 1)) + 1

Mike

Mike

"Christmas May" wrote:

If you have a cell whose contents contain a sentence of text with several
spaces, how can you find the position of the last space?

Thanks in advance,

Christmas May

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
Find position of first non-matching character Greg Lovern Excel Worksheet Functions 18 June 1st 08 01:52 AM
Insert a special character in 1st and last position into a cell Mugge New Users to Excel 5 November 6th 07 09:38 PM
Find Character Position in String SportsDave Excel Programming 6 May 21st 06 09:49 PM
Function to return Character Position of Xth character within a string Andibevan[_2_] Excel Programming 4 June 9th 05 03:24 PM
How find character position # in string from right end? Or how get range row num Ian Elliott[_3_] Excel Programming 1 December 17th 03 03:56 PM


All times are GMT +1. The time now is 12:36 AM.

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"