+ Reply to Thread
Results 1 to 8 of 8

Working with Text strings and pivot tables

  1. #1
    Registered User
    Join Date
    11-04-2016
    Location
    Ohio
    MS-Off Ver
    2010
    Posts
    17

    Working with Text strings and pivot tables

    I have a spreadsheet that reads data from a database using MS Query and the ODBC driver. The data that I am bring in contains a text string in one of the cells that represents product usage over a 12 month period. This text string is laid out in a consistent pattern of 12 block of 10 bytes for a total of 120 bytes. Because of this, the Text to column function works well to spread the data out over different columns so that I can make my pivot charts and pivot tables work. The problem I have with this, is that to make it work, I have to bring in the data in one step, and then work through the process of assigning the information to the "text to columns" in a separate step. I would like to make this easier. It would be great if I didn't have to do anything but open the file at which time the data would be updated, and the text string would be formatted and converted to separate columns, but if that is not possible I would accept a macro or similar that after pressing a button to initiate it, the macro would convert the string to columns.

    Anyone have any ideas of how to simplify this process.

  2. #2
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Working with Text strings and pivot tables

    Hi,

    You should be able to parse the data into separate columns in MSQuery using the Mid function-
    Mid(field, 1, 10)
    Mid(Field, 11, 10)
    Mid(Field, 21, 10)
    and so forth.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  3. #3
    Registered User
    Join Date
    11-04-2016
    Location
    Ohio
    MS-Off Ver
    2010
    Posts
    17

    Re: Working with Text strings and pivot tables

    I will look into this but my experience with ms query is limited. You are suggesting that I change the SQL language to include the mid function right?

  4. #4
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Working with Text strings and pivot tables

    That's correct, yes.

  5. #5
    Registered User
    Join Date
    11-04-2016
    Location
    Ohio
    MS-Off Ver
    2010
    Posts
    17

    Re: Working with Text strings and pivot tables

    This is my SQL statement. Kind of messy but it works... Any help you could give with changing it would be great. I am bolding the 2 fileds that contain text strings that I would like to break up into columns.

    SELECT "Inventory Master File".ITEM_NUMBER, "Inventory Master File".DESCRIPTION_1, "Inventory Master File".COMMITTED, "Inventory Master File".WAREHOUSE_MTD_USAGE, "Inventory Master File".WAREHOUSE_YTD_USAGE, "Inventory Master File".LAST_YEAR_USAGE, "Inventory Master File".USAGE1_12, "Inventory Master File".USAGE13_24, "Inventory Master File".MAJOR_PRODUCT_CODE, "Inventory Master File".MINOR_PRODUCT_CODE
    FROM "Inventory Master File" "Inventory Master File"
    WHERE ("Inventory Master File".ITEM_NUMBER Not Like '*%' And "Inventory Master File".ITEM_NUMBER Not Like 'CRE%' And "Inventory Master File".ITEM_NUMBER Not Like 'SPC%' And "Inventory Master File".ITEM_NUMBER Not Like 'T%') AND ("Inventory Master File".MAJOR_PRODUCT_CODE Like 'DOR%')

  6. #6
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

    Re: Working with Text strings and pivot tables

    You can add new columns by adding the functions mentioned earlier
    Please Login or Register  to view this content.
    repeating for as many columns as required.

  7. #7
    Registered User
    Join Date
    11-04-2016
    Location
    Ohio
    MS-Off Ver
    2010
    Posts
    17

    Re: Working with Text strings and pivot tables

    Great. I will give it a try and see if MS Query like the MID command.

    I will get back with you later today...

  8. #8
    Registered User
    Join Date
    11-04-2016
    Location
    Ohio
    MS-Off Ver
    2010
    Posts
    17

    Re: Working with Text strings and pivot tables

    Thanks again for your help, but I can't get this to work. I have tried to make the modification to the SQL in MS Query but it doesn't work. I get errors because it doens't like the commands. I brought in a guy who works with databases and if fluid in many languages including SQL and he has said the same thing. The combination of MS Query and Excel doesn't accept anything but some really basic commands so I am just going to live with what I have.

    Sincerely!
    Scott

+ 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. VB to add values to Pivot Tables not working.
    By cantona_lives in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-21-2015, 04:00 AM
  2. Editing Connection Strings and refreshing Pivot Tables
    By fadydaddy in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 06-03-2012, 04:29 PM
  3. Working with Pivot Tables
    By kats9137 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 12-10-2011, 11:14 AM
  4. Excel 2007 : Working with Pivot Tables in Excel 2007
    By GrahamButler1970 in forum Excel General
    Replies: 1
    Last Post: 03-04-2011, 08:13 AM
  5. [SOLVED] Working with Pivot tables with % change
    By Charlie in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 07-28-2006, 11:25 AM
  6. [SOLVED] Working with Pivot Tables
    By M.Siler in forum Excel General
    Replies: 2
    Last Post: 06-27-2005, 10:05 AM
  7. Working with Pivot Tables
    By M.Siler in forum Excel General
    Replies: 2
    Last Post: 06-27-2005, 10:05 AM

Tags for this Thread

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