+ Reply to Thread
Results 1 to 11 of 11

Text to Columns, continuously

  1. #1
    Forum Contributor
    Join Date
    01-11-2011
    Location
    Frederick, MD, USA
    MS-Off Ver
    Excel 2007
    Posts
    125

    Text to Columns, continuously

    I'm creating a template for others to use to process data that's hand-pasted in from another table in a .pdf file.

    When I first open Excel and go to past in my table, it of course tries to put all the columns into a single cell. I can use the Text to Columns function to separate them out, and (jn Excel 2007) subsequent paste-ins of other tables automatically paste in correctly, which is nice. This continues even if I close the worksheet I'm working in an open a new one, but this behavior does not continue if I close out of Excel completely and re-open.

    Because I want the worksheet I'm creating to be a template that others can use, is there a way for me to set it up so that the other users don't need to go through the text-to-column wizard at all?
    Last edited by Gunther Maplethorpe; 07-26-2011 at 04:11 PM. Reason: Mark as SOLVED

  2. #2
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,587

    Re: Text to Columns, continuously

    While pasting " text to columns " first time you are setting delimiters (tab,space,etc).After pasting first time reset all delimiters to default value and then use "text to columns" once again to paste next one selecting required delimiters.

  3. #3
    Forum Contributor
    Join Date
    01-11-2011
    Location
    Frederick, MD, USA
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Text to Columns, continuously

    No, that's not exactly helpful.

    I want to be able to save the worksheet in a state where the delimiters are already set, so that the next person who opens it can simply paste things in without having to go through the text-to-columns wizard.

    I've been able to record a macro, so that users can paste, click a command button to run the macro, which goes through the first run of text-to-columns, and then they can continue pasting as they need to...but I'd like to skip that set, too, if at all possible.

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Text to Columns, continuously

    One way would be to record a macro that does text to columns with the settings you wish. Then invoke that on an empty cell in the workbook open and workbook activate events.
    Entia non sunt multiplicanda sine necessitate

  5. #5
    Forum Contributor
    Join Date
    01-11-2011
    Location
    Frederick, MD, USA
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Text to Columns, continuously

    Ah, that's a good thought. Though I'm restricted from using "on open" settings, due to the way these workbooks will be implemented, I think I can get by with "on activate", if it's not the initial tab. As VBA is definitely NOT my forte, can you give me an example of what language to use on either side of the "active" parts of my macro?

    (That is, do I put something like "Private Sub Worksheet_Activate()" somewhere? And, can I take out hte defined range, and have it work on, say, anything pasted in on that particular tab?

    PHP Code: 
    Sub TxtToCol()
    '
    TxtToCol Macro
    '

    '
        
    Selection.TextToColumns Destination:=Range("C8"), DataType:=xlDelimited_
            TextQualifier
    :=xlDoubleQuoteConsecutiveDelimiter:=TrueTab:=True_
            Semicolon
    :=FalseComma:=FalseSpace:=TrueOther:=FalseFieldInfo _
            
    :=Array(Array(11), Array(21)), TrailingMinusNumbers:=True
    End Sub 
    Last edited by Gunther Maplethorpe; 07-26-2011 at 01:23 PM.

  6. #6
    Forum Contributor
    Join Date
    01-11-2011
    Location
    Frederick, MD, USA
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Text to Columns, continuously

    Edited the above to add in the VBA language from a simple macro recording...

  7. #7
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Text to Columns, continuously

    Try this is the worksheet module:
    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    01-11-2011
    Location
    Frederick, MD, USA
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Text to Columns, continuously

    It threw an error: "Run-time error '1004': No data was selected to parse."

    Perhaps I need to have some dummy data in there to start? (And if I did, it would need to be somewhere far from the top of the page...say, in AA1000, or somewhere.)

  9. #9
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Text to Columns, continuously

    Yup, sorry, try this:

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    01-11-2011
    Location
    Frederick, MD, USA
    MS-Off Ver
    Excel 2007
    Posts
    125

    Re: Text to Columns, continuously

    Ah, great...that seems to have worked a treat!

    In the realm of learning more VBA, is there a course/book/website you like that you could point me to where I can start learning this stuff on my own?

  11. #11
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Text to Columns, continuously

    I used Walkenbach's VBA for Dummies a few weeks ago for a class and liked it.

+ 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