+ Reply to Thread
Results 1 to 16 of 16

Query on Text to Columns

  1. #1
    Registered User
    Join Date
    03-18-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    68

    Query on Text to Columns

    Hi,

    Attached is the sample working file, i have a user data embedded into the comments columns for each user reference. However, i need to extract the wrapped comments column.

    Please advise
    Attached Files Attached Files

  2. #2
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Query on Text to Columns

    Try something like:

    Please Login or Register  to view this content.
    Adjust to suit.
    let Source = #table({"Question","Thread", "User"},{{"Answered","Mark Solved", "Add Reputation"}}) in Source

    If I give you Power Query (Get & Transform Data) code, and you don't know what to do with it, then CLICK HERE

    Walking the tightrope between genius and eejit...

  3. #3
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Query on Text to Columns

    Hi Sats ... a line return within a cell is a character which code is chr(10). So if you write code to run through each row, look at the comments cell and determine whether that character is present, you can split out the text and create duplicate rows with the separate comments. I suggest using the Instr function; if the return value is greater than zero, there are line returns in the cell; if it = zero, there are not. The same approach, looking for the ^ character, can be used to populate the separate columns for each line found. So this will find the three lines (run it in a loop until it = 0):
    Please Login or Register  to view this content.
    and this will find the three values for the columns:
    Please Login or Register  to view this content.
    MatrixMan.
    --------------------------------------
    If this - or any - reply helps you, remember to say thanks by clicking on *Add Reputation.
    If your issue is now resolved, remember to mark as solved - click Thread Tools at top right of thread.

  4. #4
    Forum Contributor
    Join Date
    07-10-2012
    Location
    Bangladesh
    MS-Off Ver
    Excel 2007
    Posts
    129

    Re: Query on Text to Columns

    attached for your reff

    regards
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    03-18-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: Query on Text to Columns

    Thanks to you both .. but your solutions are bouncing my head, can you please incorporate this code in my excel file and send it back to me. I tried the above options .. but i believe i am doing something wrong.

  6. #6
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Query on Text to Columns

    XL Split Function.xlsm

    I like Olly's solution ... Split function .. nice :-)

    One very small addition under the comment:

    Please Login or Register  to view this content.
    Last edited by MatrixMan; 07-11-2014 at 06:31 AM. Reason: Added sample file

  7. #7
    Registered User
    Join Date
    03-18-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: Query on Text to Columns

    Great ! working perfectly

  8. #8
    Valued Forum Contributor
    Join Date
    09-19-2008
    Location
    It varies ...
    MS-Off Ver
    Office365 - 64bit
    Posts
    862

    Re: Query on Text to Columns

    Please give credit to Olly :-)

  9. #9
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Query on Text to Columns

    Glad it does what you wanted - thanks for the feedback. And thanks MatrixMan for uploading a sample workbook - appreciate the help

  10. #10
    Registered User
    Join Date
    03-18-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: Query on Text to Columns

    Hi Olly,

    I need to run this report and paste it into another sheet next to it .. how do i do that?

    Thanks

  11. #11
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Query on Text to Columns

    Something like:
    Please Login or Register  to view this content.
    Change the worksheet names as necessary.

  12. #12
    Registered User
    Join Date
    03-18-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: Query on Text to Columns

    Thanks Olly,

    But It says subscription out of range, please suggest

  13. #13
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Query on Text to Columns

    Attach your file.

  14. #14
    Registered User
    Join Date
    03-18-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: Query on Text to Columns

    Hi Olly,

    Here is the attachment.
    Attached Files Attached Files

  15. #15
    Forum Expert Olly's Avatar
    Join Date
    09-10-2013
    Location
    Darlington, UK
    MS-Off Ver
    Excel 2016, 2019, 365
    Posts
    6,284

    Re: Query on Text to Columns

    You haven't changed the worksheet names...

    In your workbook, Sheet2 is the source, and Sheet1 is the target...

    So swap those names over in the code:
    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    03-18-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    68

    Re: Query on Text to Columns

    Gotcha .. my bad .. thanks

+ 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. pull text from 2 columns based on finding text in other columns
    By jimcuk in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 11-03-2013, 09:21 AM
  2. Refresh query from text source without manually selecting text file each time
    By ALN1991 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-28-2013, 01:13 PM
  3. Try to us VB to separate text to columns after retrieving data from a web query
    By jhaycen in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-15-2013, 05:09 PM
  4. Web Query Help? - Query Picture Title or Alt Text on a webpage?
    By teamtrav in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-23-2012, 06:33 PM
  5. Query Data in hidden rows/columns with Query Box
    By VincetOmnia in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-12-2009, 10:53 PM

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