+ Reply to Thread
Results 1 to 17 of 17

Text to Columns, can't stop it..

  1. #1
    Registered User
    Join Date
    10-04-2011
    Location
    Salem, Oregon
    MS-Off Ver
    Excel 2010
    Posts
    60

    Question Text to Columns, can't stop it..

    Using Excel 2010...I copy & paste a column of numbers into Cell A1, Sheet 1. Example below.

    1.000000 0.002400
    0.950000 0.010500
    0.900000 0.020200
    0.800000 0.042100
    0.700000 0.064900
    0.600000 0.086800
    0.500000 0.105500

    Then activate through a Command Button on Sheet 1 that's linked to a 'Text to Columns' macro. Works fine the first time through but clearing the sheet, then entering more data in Col A, it automatically runs the macro again.....Currently I have to close the program and reopen it....I need it to stop this until I click on the Command Button.....Probably something very simple but escapes me.....TIA...

    Don

  2. #2
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Text to Columns, can't stop it..

    Sounds like you could have something triggering a macro to run automatically
    Right click on the sheet tab \ select View Code
    - what is in the code window?

    What is in the code behind the button?
    Click *Add Reputation to thank those who helped you. Ask if anything is not clear

  3. #3
    Registered User
    Join Date
    10-04-2011
    Location
    Salem, Oregon
    MS-Off Ver
    Excel 2010
    Posts
    60

    Re: Text to Columns, can't stop it..

    Please Login or Register  to view this content.
    There is the code that is attached to the Button....the Button was just assigned to that Sub, no other code in it...

    As you can see the macro also Concantenates the data back into the proper format (separated by a comma)

    Don

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Question Re: Text to Columns, can't stop it..

    Maybe:

    Please Login or Register  to view this content.
    *But , I wonder why you're copying F there at the end??
    Last edited by xladept; 04-05-2018 at 11:00 PM.
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  5. #5
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Text to Columns, can't stop it..

    VBA does not require objects to be selected
    avoid selection with ...
    Please Login or Register  to view this content.
    Like xladept, I wonder why you are copying column F when it is not pasted anywhere
    but avoid selection with ...
    Please Login or Register  to view this content.
    There is nothing the code you provided to make it run more than once
    - is this the ONLY code in your workbook?
    - suggest you attach a sample workbook so we can look at it (Remember to desensitize any data)

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

  6. #6
    Registered User
    Join Date
    10-04-2011
    Location
    Salem, Oregon
    MS-Off Ver
    Excel 2010
    Posts
    60

    Re: Text to Columns, can't stop it..

    Using the code posted above I received a Run-time error '1004'.....

    Have attached the WB and also a Text file (E207.txt) to use for testing.

    The WB when opened shows three 'Command Buttons' and some data in Col L

    I would like to hide or protect those populated cells in Col L in some way as they will never change but that data
    needs to be available for the next 'BUILD DAT FILE' macro..this is not important at this time.

    'PROCESS DATA'
    'BUILD DAT FILE'
    'CLEAR SHEET'

    The populated Cells in Col L contain data that is relevant to every use,
    this data is not cleared by the 'CLEAR SHEET' button.

    First: Enter data from text file, row 4 to bottom line, in A1. This will populate down Col A.

    Then click on 'Process Data', some processing will occur and a small form will open requiring name and thickness.
    The required data, in this case, is 'E207' for name and .296 for % of thickness.

    Enter that data and click 'Continue' and the data will be further processed into Col F and where needed in Col L

    Clicking 'Build Dat File' will further process the data and populate same in Col M into the format required.
    Col M is also selected and copied onto clipboard by code for transfer to a text editor.

    I'm fairly certain that the problem is in the first module as, the first use runs fine, but does the automatic 'data to columns'
    when attempting to use the program a second time without closing and reopening it.

    As to why I selected Col F, I can only guess that I thought that was needed for the 'AutoFit' command....In the attached WB
    I've commented that out and the program runs successfully, but only on the first run through.....

    Please excuse the amateur like code, I'm not a pro at this.....Thanks for your interest in helping me here....

    Don
    Attached Files Attached Files

  7. #7
    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: Text to Columns, can't stop it..

    Once you have run Text To Columns, Excel will reapply those settings if you then paste delimited data (it doesn't actually run your code again, unless you have something triggering it). To prevent that, you either restart Excel, or run a Text To Columns operation with no delimiters specified.
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  8. #8
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Text to Columns, can't stop it..

    Once you have run Text To Columns, Excel will reapply those settings if you then paste delimited data
    @xlnitwit -

    I was not aware of that, so I tested it
    - put data in columnA
    - ran TextToColumns with delimiter specified
    - pasted fresh delimited data into column A
    - nothing happened
    - created VBA for TextToColumns with delimiter specified
    - ran VBA
    - pasted fresh data
    - nothing happened

    What you say mirrors OP problem - so what you are saying is correct
    But I cannot replicate - it. So something must be different. If we find out what is different perhaps that would solve OP problem
    Any ideas

    Excel 2016 behaves differently to 2010 perhaps??

    EDIT
    Or are you saying If you "deliberately" run TextToColums again it retains its old settings ?
    - that I can replicate

    If that is the case, how about resetting everything like this:
    (after original TextToColumns add a line in VBA to)
    - run "dummy" TextToColumns without a delimiter against a "dummy" cell
    (cell must contain text)
    Last edited by kev_; 04-06-2018 at 07:56 AM.

  9. #9
    Registered User
    Join Date
    10-04-2011
    Location
    Salem, Oregon
    MS-Off Ver
    Excel 2010
    Posts
    60

    Re: Text to Columns, can't stop it..

    I tried to run the TextToColumns with no delimiters after running the program one time. But you need data for it to work, but no matter what cell I
    tried to put data in to run the TextToColumns with no delimiters, the TextToColumns immediately runs with delimiters.

    Maybe a solution will be to test A1 when the 'Process Data' button is clicked...if A1 has data run with delimiters, if A1 has no data then run the balance of that macro. Pasting the data for the second run into Col A will be processed with delimiter to Col B and C.

    Let me play with this a bit and I'll post my results back here....Thanks again for the input.
    Last edited by AliGW; 04-06-2018 at 09:43 AM. Reason: Unnecessary quotations removed.

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2405 (Windows 11 23H2 64-bit)
    Posts
    81,405

    Re: Text to Columns, can't stop it..

    Please don't quote whole posts, especially when you are responding to the one immediately preceding your own - it's just clutter. It's OK to quote if you are responding to a post out of sequence, but limit quoted content to a few relevant lines that makes clear to whom and what you are responding. Thanks!

    For normal conversational replies, try using the QUICK REPLY box below.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  11. #11
    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: Text to Columns, can't stop it..

    You seem to be splitting on a Space, so just select any populated cell, and then:
    Data- Text to Columns
    Choose Delimited
    Click Next
    Enable the Tab delimiter and disable all the others
    Clear 'Treat consecutive delimiters as one'
    Click Finish
    Then try pasting your data again

  12. #12
    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: Text to Columns, can't stop it..

    Quote Originally Posted by kev_ View Post
    Excel 2016 behaves differently to 2010 perhaps??
    I would suspect that must be the difference.

    If that is the case, how about resetting everything like this:
    (after original TextToColumns add a line in VBA to)
    - run "dummy" TextToColumns without a delimiter against a "dummy" cell
    (cell must contain text)
    Yes, that's basically what I am suggesting to allow the paste to work as normal.

  13. #13
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Text to Columns, can't stop it..

    how about putting the reset into the VBA as the last command
    - run it against a cell that is guaranteed to contain text

  14. #14
    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: Text to Columns, can't stop it..

    I have just realised that I forgot to mention a crucial piece of information. This auto-split only happens when copying from another non-Office application- e.g. a web page.

  15. #15
    Forum Expert
    Join Date
    11-22-2016
    Location
    Cornwall,UK
    MS-Off Ver
    office 365
    Posts
    4,240

    Re: Text to Columns, can't stop it..

    Ah - that explains why I could not replicate
    Would pasting to a dummy range first and then copy/pasting from there to the correct column fix OP problem?

  16. #16
    Registered User
    Join Date
    10-04-2011
    Location
    Salem, Oregon
    MS-Off Ver
    Excel 2010
    Posts
    60

    Re: Text to Columns, can't stop it..

    It works....added a snippet to the clearing macro and tested the WB a few times. Also cleaned up the code a bit. I'll mark it Solved! Thanks to you all..have a great weekend....

    Please Login or Register  to view this content.
    Don

  17. #17
    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: Text to Columns, can't stop it..

    I doubt it- Excel would simply parse the first paste to numerous columns. A dummy TTC routine is the simplest way to go, in my opinion.

+ 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. [SOLVED] How to get a text in a cell and excel knows where to stop getting the text
    By Lan Tran in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 07-16-2015, 07:08 AM
  2. [SOLVED] Text to Columns is omitting zeros. How do I stop that?
    By jambog in forum Excel General
    Replies: 5
    Last Post: 07-02-2015, 11:26 AM
  3. Replies: 2
    Last Post: 10-16-2014, 05:45 AM
  4. How to stop automatically converting text columns to date values
    By andy.k in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-07-2013, 10:55 AM
  5. How to stop text to columns automatically parsing
    By mystic342005 in forum Excel General
    Replies: 2
    Last Post: 02-21-2008, 09:49 PM
  6. Replies: 2
    Last Post: 06-12-2006, 08:00 PM
  7. [SOLVED] Tab Stop across Columns
    By [email protected] in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 03-13-2005, 12:06 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