Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Extract word after 3 spaces

Hi,
How can I extract a word from a cell when the word I want to extract is
always 2 spaces away starting counting spaces from the right.

Example:
Cell A1: Car, black 66,00 52,80
The word I want to extract is "Car, black"
Formula to be used in cell A2?
Or perhaps a macro?

Thank you in advance.

Kaj Pedersen

---
Denne e-mail blev kontrolleret for virusser af Avast antivirussoftware.
http://www.avast.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Extract word after 3 spaces

Hi,
How can I extract a word from a cell when the word I want to extract
is always 2 spaces away starting counting spaces from the right.

Example:
Cell A1: Car, black 66,00 52,80
The word I want to extract is "Car, black"
Formula to be used in cell A2?
Or perhaps a macro?

Thank you in advance.

Kaj Pedersen

---
Denne e-mail blev kontrolleret for virusser af Avast
antivirussoftware. http://www.avast.com


Perhaps a UDF...


Function ParseInstrRev2$(rng As Range)
Dim vTmp
vTmp = Split(rng, " ")
ParseInstrRev2 = vTmp(UBound(vTmp) - 2)
End Function

...and use as follows in the cell to receive the result...

=ParseInstrRev2(A1)

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Extract word after 3 spaces

Il giorno mercoledì 4 marzo 2015 22:24:57 UTC+1, ha scritto:
How can I extract a word from a cell when the word I want to extract is
always 2 spaces away starting counting spaces from the right.
Example:
Cell A1: Car, black 66,00 52,80
The word I want to extract is "Car, black"
Formula to be used in cell A2?
Or perhaps a macro?


Hi,
=LEFT(A1,FIND(" ",A1)-1)
-OR-
=LEFT(A1,FIND(CHAR(32)&CHAR(32),A1)-1)
--
Ciao!
Maurizio
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Extract word after 3 spaces

Ciao Maurizio,

Am Wed, 4 Mar 2015 23:22:32 -0800 (PST) schrieb Maurizio Borrelli:

=LEFT(A1,FIND(" ",A1)-1)


oh yes. I need new glasses. I did not realize the *2spaces*


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Extract word after 3 spaces

Il giorno giovedì 5 marzo 2015 08:33:04 UTC+1, Claus Busch ha scritto:
Am Wed, 4 Mar 2015 23:22:32 -0800 (PST) schrieb Maurizio Borrelli:
=LEFT(A1,FIND(" ",A1)-1)

oh yes. I need new glasses. I did not realize the *2spaces*


:-D
--
Ciao!
Maurizio
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Extract word after 3 spaces

Ciao Maurizio,

Am Wed, 4 Mar 2015 23:22:32 -0800 (PST) schrieb Maurizio Borrelli:

=LEFT(A1,FIND(" ",A1)-1)


oh yes. I need new glasses. I did not realize the *2spaces*


Regards
Claus B.


Now what if there really are 3 spaces as the topic title suggests...

car,black whitewalls 60.00 52.80

...where the correct result becomes "whitewalls" if persisting the
'always 2 spaces' criteria?

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Extract word after 3 spaces

Hi Garry,

Am Thu, 05 Mar 2015 03:15:32 -0500 schrieb GS:

Now what if there really are 3 spaces as the topic title suggests...


I guess the OP counts the spaces from left to right.

car,black whitewalls 60.00 52.80


car, black whitewalls 60.00 52.80

..where the correct result becomes "whitewalls" if persisting the
'always 2 spaces' criteria?


Find(" "; A1) finds two connected spaces and gives the correct result
if always are two spaces between the text and the numbers.


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Extract word after 3 spaces

Il giorno giovedì 5 marzo 2015 09:15:43 UTC+1, GS ha scritto:
Am Wed, 4 Mar 2015 23:22:32 -0800 (PST) schrieb Maurizio Borrelli:
=LEFT(A1,FIND(" ",A1)-1)

oh yes. I need new glasses. I did not realize the *2spaces*

Now what if there really are 3 spaces as the topic title suggests...
car,black whitewalls 60.00 52.80
..where the correct result becomes "whitewalls" if persisting the
'always 2 spaces' criteria?


Hi.
Word(s?) after or before 3 spaces!?
Only OP can decide. :-)
=LEFT(A1,FIND(CHAR(32)&CHAR(32)&CHAR(32),A1)-1)
-OR-
=MID(A4,FIND(CHAR(32)&CHAR(32)&CHAR(32),A4)+3,LEN( A4))
--
Ciao!
Maurizio
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Extract word after 3 spaces

Hi Garry,

Am Thu, 05 Mar 2015 03:15:32 -0500 schrieb GS:

Now what if there really are 3 spaces as the topic title suggests...


I guess the OP counts the spaces from left to right.

car,black whitewalls 60.00 52.80


car, black whitewalls 60.00 52.80

..where the correct result becomes "whitewalls" if persisting the
'always 2 spaces' criteria?


Find(" "; A1) finds two connected spaces and gives the correct
result if always are two spaces between the text and the numbers.


Regards
Claus B.


Wow! I totally missed the double space!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion




  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Extract word after 3 spaces

Hi Garry,

Am Thu, 05 Mar 2015 03:32:27 -0500 schrieb GS:

Wow! I totally missed the double space!


you need new glasses also ;-)


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Extract word after 3 spaces

Might be better to revise criteria to delimit at the " "!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Extract word after 3 spaces

Hi Garry,

Am Thu, 05 Mar 2015 03:32:27 -0500 schrieb GS:

Wow! I totally missed the double space!


you need new glasses also ;-)


Regards
Claus B.


I don't wear glasses, but perhaps I should!<g

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


  #14   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Extract word after 3 spaces

Hi Claus and Maurizio

Thank you very much for all of your proposals.

This works to my full satisfaction: =LEFT(A1,FIND(" ",A1)-1) [it also
works even if I don't add "-1"]
I start counting spaces from the right (Car, black 66,00 52,80)

However, now I can't figure out the formula if I want to extract the amount
after 1 space from the right, in this case "66,00"
Can you help once again?

Best regards,
Kaj Pedersen

---
Denne e-mail blev kontrolleret for virusser af Avast antivirussoftware.
http://www.avast.com

  #15   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Extract word after 3 spaces

Try...

Function ParseInstrRev2(rng As Range)
' Returns 1st word left of " "
ParseInstrRev2 = Split(rng, " ")(0)
End Function

Function ParseInstrRev1(rng As Range)
' Returns 1st value left of last " "
Dim vTmp
vTmp = Split(rng, " ")
'Convert text to currency
ParseInstrRev1 = CCur(Split(vTmp(1), " ")(0))
End Function

Function ParseInstrRev0(rng As Range)
' Returns last value
Dim vTmp
vTmp = Split(rng, " ")
'Convert text to currency
ParseInstrRev0 = CCur(Split(vTmp(1), " ")(1))
End Function

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion




  #17   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Extract word after 3 spaces

Hi Claus,

Thank you. It works perfectly.

Kaj Pedersen



On 5-Mar-2015, Claus Busch wrote:

try:
=--MID(A1,FIND(" ",A1)+2,5)
The double minus at start are to change text to number


---
Denne e-mail blev kontrolleret for virusser af Avast antivirussoftware.
http://www.avast.com

  #18   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Extract word after 3 spaces

Hi Garry,

Thank you for your proposal. I have not yet tested but I'm sure it works :-)
If not, I will revert.

Kaj Pedersen

---
Denne e-mail blev kontrolleret for virusser af Avast antivirussoftware.
http://www.avast.com

  #19   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,872
Default Extract word after 3 spaces

Hi Kaj,

Am Thu, 5 Mar 2015 13:39:44 GMT schrieb :

Thank you. It works perfectly.


you are welcome.
If you want all parts of your string in a seperate cell use Data = Text
to columns


Regards
Claus B.
--
Vista Ultimate / Windows7
Office 2007 Ultimate / 2010 Professional
  #20   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Extract word after 3 spaces

Garry, now tested and works to my full satisfaction.
Also very good description you provided. Thank you.
I will keep it for ever in my archive of good Excel tips :-)

Kaj Pedersen

---
Denne e-mail blev kontrolleret for virusser af Avast antivirussoftware.
http://www.avast.com



  #21   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,514
Default Extract word after 3 spaces

Garry, now tested and works to my full satisfaction.
Also very good description you provided. Thank you.
I will keep it for ever in my archive of good Excel tips :-)

Kaj Pedersen

---
Denne e-mail blev kontrolleret for virusser af Avast
antivirussoftware. http://www.avast.com


Glad to help! I appreciate the feedback.

FWIW
Claus' suggestion to use DataTextToCols is a good way to parse into
contiguous cols. Using the UDFs allows parsing to any location of your
sheet[s], meaning that on Sheet2 for example...

=ParseInstrRev2(Sheet1!A1)

...also may prove to be of some benefit!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion


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
extract text between two spaces anthony Excel Discussion (Misc queries) 5 April 21st 23 05:24 PM
Extract all text without spaces and special characters Alfredo_CPA Excel Worksheet Functions 4 September 18th 08 11:39 PM
how do I reduce the spaces between letters in a word? Spaces between letters Excel Discussion (Misc queries) 1 June 10th 08 05:50 PM
How to remove spaces from a word in a cell Jerry Excel Discussion (Misc queries) 5 January 15th 07 08:11 PM
how do i extract a number from a cell with no spaces? Mulvaney Excel Worksheet Functions 4 July 26th 05 09:15 PM


All times are GMT +1. The time now is 12:45 PM.

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

About Us

"It's about Microsoft Excel"