+ Reply to Thread
Results 1 to 5 of 5

extract text from variable length strings in text file

  1. #1
    Registered User
    Join Date
    07-05-2018
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    26

    extract text from variable length strings in text file

    I have a variety of text files that contains a string that is not of a fixed length. It could be similar to any of the three following examples. The variable string length is where I'm stuck.

    Some stuff here
    ( G54.1P1 = X-504.13 Y-215.137 Z-244. )
    More stuff
    Even more stuff

    Some stuff here
    ( G54.1P1 = X-504.456 Y-215.137 Z-241.129 )
    More stuff
    Even more stuff

    Some stuff here
    ( G54.1P1 = X-503. Y-215.28 Z-244. )
    More stuff
    Even more stuff


    I'd like to use a button, probably using Application.GetOpenFilename(), to find the text file, and place the 1st numerical value in A1, 2nd in A2, and 3rd in A3.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,715

    Re: extract text from variable length strings in text file

    The stuff - what sort of stuff is that? The problem will be that the data you wish to extract is not numerical - it may look like numbers, but it’s text.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help. It's a universal courtesy.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    NB:
    as a Moderator, I never accept friendship requests.
    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    07-05-2018
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    26

    Re: extract text from variable length strings in text file

    The stuff is code for a CNC machine. Text, letters, numbers.


    So far, I'm able to get some of the information using

    Please Login or Register  to view this content.
    But the variable string length causes issues. I was thinking of pulling all the information into one cell and separating it later, but I figure there's probably a way to be more precise.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (both in England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2504 (Windows 11 Home 24H2 64-bit)
    Posts
    90,715

    Re: extract text from variable length strings in text file

    Are you able to provide a sample text file?

  5. #5
    Registered User
    Join Date
    07-05-2018
    Location
    Canada
    MS-Off Ver
    2016
    Posts
    26

    Re: extract text from variable length strings in text file

    Here's a portion of a text file:

    %
    O1975( 402975.02.01 1ST.NCF )
    ( GIBBSCAM VERSION: 11.3.7 64 BIT )
    ( FORMAT: MATSUURA GTECH 30I MILL [RPM] C2239.26.9M.POST )
    ( MDD: NEW MATSUURA GTECH 30I 5 AXIS VERTICAL MILL - REDLINE PRO MAN - V11.3.MDD REV: 1 )
    ( 7/23/2019 AT 10:31 AM )
    ( OUTPUT IN ABSOLUTE MILLIMETERS )
    ( PARTS PROGRAMMED: 1 )
    ( FIRST TOOL NOT IN SPINDLE )
    N1M800M1
    G21
    G0G17G40G43G49G52G80G90G98M9
    G53Z0.M5
    M1
    G17G21G40G80
    T1M6
    T4
    ( OPERATION 1: ROUGHING )
    ( A0C0 STOCK )
    ( TOOL 1: 50.8 DIA. FACE ENDMILL )
    ( 2" KENNAMETAL FACE MILL )
    ( CS#2 - A0C0 )
    ( G54.1P1 = X-504.13 Y-215.137 Z-244. )
    G54.1P1
    S6000M3
    G90G0X56.4Y-20.4
    G65P8023A0.C0.
    G43Z80.H1
    M8
    Z10.
    G1Z.2F1500.
    X-77.9
    G0Y20.4
    G1X56.4
    G0Z10.
    ( OPERATION 2: ROUGHING )
    ( A0C0 STOCK )
    ( TOOL 1: 50.8 DIA. FACE ENDMILL )
    ( 2" KENNAMETAL FACE MILL )
    ( CS#2 - A0C0 )

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Extract min of variable length numbers after text
    By Xenthys in forum Excel General
    Replies: 10
    Last Post: 10-18-2017, 11:30 AM
  2. Removing various different text, from varying length text strings
    By cloudwalking in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-04-2013, 10:37 AM
  3. Extract Variable Length Text String
    By sshot1 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 11-12-2012, 06:21 PM
  4. Extract fixed number from variable text strings
    By IM22 in forum Excel General
    Replies: 27
    Last Post: 05-14-2012, 08:19 PM
  5. Replies: 6
    Last Post: 03-08-2012, 10:35 AM
  6. Extract variable length of text from cell
    By stonegwene in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-12-2011, 03:38 AM
  7. [SOLVED] EXTRACT TEXT FROM TEXT STRING:The names are of variable length
    By carricka in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-08-2005, 06:05 AM

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