+ Reply to Thread
Results 1 to 12 of 12

Correct approach? (Multiple MID functions)

  1. #1
    Registered User
    Join Date
    05-29-2007
    Location
    Kentucky
    Posts
    6

    Correct approach? (Multiple MID functions)

    Hello - I just joined this forum and I am very happy to have found this place! Here is my question:

    * I have a complex Excel workbook with several worksheets.
    * The first worksheet is for raw data, which consists of a single string of data, separated by spaces, to be uploaded to a mainframe. There is no consistent pattern of length of data or strings in between pieces of data, which can vary widely. An example of the data would be something like this:

    XXXXX YYYYY NN XXXXXXX

    * For testing purposes, I need to come up with a way to parse the data for easier viewing. The current approach is this:

    * Take the string and divide it up into individual cells by using the MID function. In the above approach, this would split the data into four (4) different cells.

    The main disadvantage that I see are how to maintain all these MID functions without going crazy, LOL.

    This is going to be a very complex workbook with data strings that can have 20+ elements in them, and have lots of separate records, etc. While this way should work (if everything is entered perfectly and no data structures ever change, etc.), I was wondering if conceptually, there is an easier way to accomplish my goal.

    Thanks in advance for your time and consideration!

  2. #2
    Valued Forum Contributor
    Join Date
    09-07-2006
    Posts
    520
    One thought ...

    Use Data > Text to Columns (Delimited > Space) to split the col
    Max
    Singapore

  3. #3
    Registered User
    Join Date
    05-29-2007
    Location
    Kentucky
    Posts
    6

    More questions

    Thanks for the quick reply! I had wanted to use this command, but the spaces between the data are not uniform. Also, it is a space character and not a comma or tab.

    For example, the data string (all on the same line) may look something like this:

    XXXXXXXXX (then add 6 spaces)
    YYYYYY (then add 3 spaces)
    NNNNNNNN (then add 11 spaces)
    and so on....

    Any more ideas how this could work?

  4. #4
    Valued Forum Contributor
    Join Date
    09-07-2006
    Posts
    520
    [QUOTE=Harmony]
    Thanks for the quick reply! I had wanted to use this command, but the spaces between the data are not uniform. Also, it is a space character and not a comma or tab.

    For example, the data string (all on the same line) may look something like this:

    XXXXXXXXX (then add 6 spaces)
    YYYYYY (then add 3 spaces)
    NNNNNNNN (then add 11 spaces)
    and so on....

    I'm not sure why using Data > Text to Columns doesn't seem to work for you?

    After selecting the col, click Data > Text to Columns
    In step 1 of the wizard, check "Delimited"
    In step 2: think you could check "Space", then just click Finish

    The number of spaces in-between is immaterial (it could be one or several spaces), the data will be split nicely into the different cols.

  5. #5
    Registered User
    Join Date
    05-29-2007
    Location
    Kentucky
    Posts
    6
    Yes, but will this work if the data strings (within each record) are different lengths each time?

    In other words, the column lengths may differ, but will always be constrained by a maximum length. Then, somehow I would need to trim off the extra spaces, but this number of spaces may be different from record to record.

    Does that make sense?

  6. #6
    Valued Forum Contributor
    Join Date
    09-07-2006
    Posts
    520
    Quote Originally Posted by Harmony

    Yes, but will this work if the data strings (within each record) are different lengths each time?

    In other words, the column lengths may differ, but will always be constrained by a maximum length. Then, somehow I would need to trim off the extra spaces, but this number of spaces may be different from record to record.

    Does that make sense?
    I might not have/be reading your requirements right. Can you post a small sample of your data, and the expected results?

  7. #7
    Registered User
    Join Date
    05-29-2007
    Location
    Kentucky
    Posts
    6
    Hi Max,

    It is difficult to post a data sample, because the extra spaces keep getting stripped out. Imagine something like this (where the phrase "extra spaces" is literally tapping the spacebar), all in a single string:

    XXXXXX (plus six spaces)
    NNNNN (plus eleven spaces)
    XXX (plus three spaces)
    and so forth

    What I want the result to be is to parse out the string onto a separate worksheet, with each separate data value represented in the string to be placed in a separate column. (The purpose of this is so the individual columns can be filtered to inspect the data more easily, rather than inspecting a single long string.)

    Does this make sense?

  8. #8
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454
    Hi Harmony,

    I've attached what I believe to be an example of the data you receive (Sheet 1) and the format you want it in (Sheet 2). Can you please confirm this is the case?

    Dave
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    05-29-2007
    Location
    Kentucky
    Posts
    6
    Hi sweep,

    Yes, that is very similar!

  10. #10
    Forum Expert sweep's Avatar
    Join Date
    04-03-2007
    Location
    Great Sankey, Warrington, UK
    MS-Off Ver
    2003 / 2007 / 2010 / 2016 / 365
    Posts
    3,454
    The example was achieved as follows:

    Select the whole column that the data is in.

    Go to Data > Text To Columns

    Select delimited > Click Next

    Select "Space" > Click Next

    Click Finish
    Rule 1: Never merge cells
    Rule 2: See rule 1

    "Tomorrow I'm going to be famous. All I need is a tennis racket and a hat".

  11. #11
    Registered User
    Join Date
    05-29-2007
    Location
    Kentucky
    Posts
    6
    Thanks so much! This seems to be working and a *lot* simpler than using compounded MID functions

  12. #12
    Valued Forum Contributor
    Join Date
    09-07-2006
    Posts
    520
    Glad to hear you got it (Data > Text to Columns) to work for you, finally <g>.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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