View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Claus Busch Claus Busch is offline
external usenet poster
 
Posts: 3,872
Default Extract text from text string

Hi John,

Am Tue, 9 Feb 2021 06:44:13 -0800 (PST) schrieb john taiariol:

(M72)
G0G54X202.819Z54.5
#590=2(RECOVER_FACE TURN)
G1X167.751F#101M26
G0Z61.398
X163.682
G1 X 153.873 Z 62
X147.873
G0X162.375Z62.394

My preference would be a formula. I would like the adjacent cell to contain only the value for "X" ie. in the first line "G0G54X202.819Z54.5", the X-coord is 202.819. Please note sometimes the text may have a space after the X or after the coordinate. It is not consistent. I have tried "find" and "mid" with limited success. I was wondering if it's possible to analyze each character in the string after the "X" and verify if it's a number or a period. Thank you in advance for any help.


try:
=IF(COUNT(FIND({"X","Z"},A1))=2,TRIM(MID(LEFT(A1,F IND("Z",A1)-1),FIND("X",LEFT(A1,FIND("Z",A1)-1))+1,99)),IF(COUNT(FIND({"X","F"},A1))=2,TRIM(MID (LEFT(A1,FIND("F",A1)-1),FIND("X",LEFT(A1,FIND("F",A1)-1))+1,99)),IF(COUNT(FIND({"F","Z"},A1))=0,TRIM(SUB STITUTE(A1,"X",)),"")))

Regards
Claus B.
--
Windows10
Microsoft 365 for business