Extracting defined elements from .txt and placing them in columns/rows in Excel

  • Hello,


    Would you be so kind as to help me with a macro that would extract specific lines and "codes" from text files and place them into excel



    This is what I've been able to piece together



    What I haven't been able to do is
    a. Define

    Code
    ("P1:", "P2:", "P3:")


    Somewhere in my workbook e.g. cells I3 to I5 - so that I can modify these parameters with ease from excel without opening VBA
    b. Add a code that will allow me to extract elements from the text file that are delimited by the values that I place in cells I6 and I7; and place this code in E3, E4, E5, etc



    A clear example of what I want to try to achieve
    This would be the contents of the text file
    [SIZE=9px]P1: 12345
    P2: ABC
    P3: 300x250
    Lorem ipsum dolor sit amet, nec ea aperiri nostrud, dicam scripta officiis id eam, pri et putent honestatis. Sed cu nostrud fabulas fastidii, causae recusabo et pri.
    <script>
    Nec labores vituperata id, cum luptatum menandri voluptaria eu, nominavi hendrerit consectetuer eos ea.
    </noscript>
    P1: 678910
    P2: DEF
    P3: 320x250
    Lorem ipsum dolor sit amet, nec ea aperiri nostrud, dicam scripta officiis id eam, pri et putent honestatis. Sed cu nostrud fabulas fastidii, causae recusabo et pri1.
    <script>
    Nec labores vituperata id, cum luptatum menandri voluptaria eu, nominavi hendrerit consectetuer eos ea1.
    </noscript>
    P1: 54321
    P2: CBA
    P3: 300x250
    Lorem ipsum dolor sit amet, nec ea aperiri nostrud, dicam scripta officiis id eam, pri et putent honestatis. Sed cu nostrud fabulas fastidii, causae recusabo et pri2.
    <script>
    Nec labores vituperata id, cum luptatum menandri voluptaria eu, nominavi hendrerit consectetuer eos ea2.
    </noscript>[/SIZE]


    Using the macro I would achieve
    [ATTACH=JSON]{"data-align":"none","data-size":"full","title":"VBAMacro.jpg","data-attachmentid":1205900}[/ATTACH]
    Is something like this possible?
    Appreciate your time looking at this - thank you!

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!