Excel User Group
Microsoft Excel blogs, forums, files. Read, ask questions, provide answers.

Can a formula be written in excel or VBA to perform the "text to column" function ?

Latest post Fri, Apr 9 2010 3:07 PM by WISHWELLS. 30 replies.
  • Mon, Jan 18 2010 12:13 PM

    • WISHWELLS
    • Top 50 Contributor
    • Joined on Mon, Jan 18 2010
    • Posts 19
    • Points 303

    Can a formula be written in excel or VBA to perform the "text to column" function ?

     

    Hello I am new to the group and need help with a worksheet I am working on.

    I have a column on an excel worksheet (excel 2003)  which contains the name and description of a retail product, the retail price, the labor price to install it (which are selected from a drop down list) .  I would like to be able to expand that column into three columns with a macro.  These separate fields are separated by a comma at present and if I use the  text to column feature it does work but due to un-computer savy employees I would like a button for them to push to perform this function after they have made their entries.

    Can this be done and how?

    Thank you!

    Lynn

    • Post Points: 21
  • Tue, Jan 19 2010 4:21 AM In reply to

    Re: Can a formula be written in excel or VBA to perform the "text to column" function ?

    Why not record a macro to do the Text to Columns bit, and then assign that macro to a bjutton?

    Regards

    Bob

    • Post Points: 21
  • Tue, Jan 19 2010 9:00 AM In reply to

    • WISHWELLS
    • Top 50 Contributor
    • Joined on Mon, Jan 18 2010
    • Posts 19
    • Points 303

    Re: Can a formula be written in excel or VBA to perform the "text to column" function ?

    Bob

     

    Thank you for your quick response.  That is what I was thinking of doing however I am new to macros and have take a tutorial on them but am shy of knowledge as to how to really do this.

    If you know where more tutorials are or can help me with this I would be so grateful!

    Thank you

    Lynn

    • Post Points: 21
  • Tue, Jan 19 2010 12:28 PM In reply to

    Re: Can a formula be written in excel or VBA to perform the "text to column" function ?

    If you use the macro recorder, it will create the VBA for you.

    Regards

    Bob

    • Post Points: 21
  • Tue, Jan 19 2010 1:30 PM In reply to

    • WISHWELLS
    • Top 50 Contributor
    • Joined on Mon, Jan 18 2010
    • Posts 19
    • Points 303

    Re: Can a formula be written in excel or VBA to perform the "text to column" function ?

    I hate to sound dumb but  macro recorder?

    The tutorials I took on the excel website used the maco function but I would have to write the formula in vba myself and I don't know vba language enough to do it.  At least I am at a loss at present.

    The site said I could use the text to column funtion on the previously merged information in my cell which does work but I would like my employees to just click a button and have it hapen for them...less mistakes that way ;)

    Is there a place to go to find more tutorials?

    Thanks

    Lynn

    • Post Points: 21
  • Tue, Jan 19 2010 1:55 PM In reply to

    Re: Can a formula be written in excel or VBA to perform the "text to column" function ?

    See http://www.excel-vba.com/vba-prog-1-7-excel-macro-recorder.htm

    Regards

    Bob

    • Post Points: 21
  • Tue, Jan 19 2010 2:47 PM In reply to

    • WISHWELLS
    • Top 50 Contributor
    • Joined on Mon, Jan 18 2010
    • Posts 19
    • Points 303

    Re: Can a formula be written in excel or VBA to perform the "text to column" function ?

    Bob

    Thank you Thank you!!

    So far so good! 

    I did get it to write the code and function for the one line.

    To have it do the same for multiple lines do I highlight multiple cells at the beginning or is there another way to do it to get the macro to repeat it in that cell for each line on the worksheet?

    Lynn

     

    • Post Points: 5
  • Tue, Jan 19 2010 3:27 PM In reply to

    • WISHWELLS
    • Top 50 Contributor
    • Joined on Mon, Jan 18 2010
    • Posts 19
    • Points 303

    Re: Can a formula be written in excel or VBA to perform the "text to column" function ?

    Bob

    Ok I did figure it out for all the lines so far.

    I am having a problem getting the control button to work.

    I create the button and then create the macro but the button does not work.

    Any suggestions?

    Lynn

    • Post Points: 21
  • Tue, Jan 19 2010 6:48 PM In reply to

    Re: Can a formula be written in excel or VBA to perform the "text to column" function ?

    This forum allows attachments, so can you post your workbook and I will look at it for you.

    Regards

    Bob

    • Post Points: 36
  • Fri, Jan 22 2010 10:37 AM In reply to

    • WISHWELLS
    • Top 50 Contributor
    • Joined on Mon, Jan 18 2010
    • Posts 19
    • Points 303

    Re: Can a formula be written in excel or VBA to perform the "text to column" function ?

    Bob

    I would love to do that but I don't see an attachment button

    do I just copy paste?

    Lynn

    • Post Points: 5
  • Fri, Jan 22 2010 3:25 PM In reply to

    • WISHWELLS
    • Top 50 Contributor
    • Joined on Mon, Jan 18 2010
    • Posts 19
    • Points 303

    Re: Can a formula be written in excel or VBA to perform the "text to column" function ?

    I finally found the attachment button so here is the file...I hope

    l

    Bob,
    I have had a couple days off so that is why I didnot get back to you sooner.
    I will attach a "sample" of my worksheet.
    column a is qty
    column b is a catagory list drop down
    column c is a list of individual plant goods this is a drop down that is dependent on what column b is. so if you select trees it only shows you the tree list
    Column c is coma delimited with the prices for material and retail
    My macro separates the prices into the appropriate columns
     
    Here is my problems   1.  this works fine if they enter all their items and run the macro  (control z) 
     
                        however if they change and item or add another item and re-run the macro it doesn't just do the new ones
                        it reruns the rest and because there are no prices on those lines because they have been done already it sets
                        those prices to zero.
     
                                    2. I cannot get a button for them to use so they don't have to use control z
     
    This is only partially set up as far as the drop down menus
    so in column b  you can use garden rose and shrub rose.  those are the only two that have inventory items lists attached to them at this time to fill in column c.
     
    Thank you
    Lynn
    PS  I am learning alot !

    ynn

    • Post Points: 21
  • Fri, Jan 22 2010 7:16 PM In reply to

    Re: Can a formula be written in excel or VBA to perform the "text to column" function ?

    Lynn,

    I wouldn't use Text To Columns with yor data setup as it, as the dataset is so small I would use a simple lopp macro and test the current setup.

    BTW, the way that you are creating dependent dropdowns will run out of steam very quickly, pre-2007 Excel only allows 7 nested functions.

    I have another way of creating dependent dropdowns which allows any number., It is a tad complex, but I could insert it if you wish.

    Regards

    Bob

    Regards

    Bob

    • Post Points: 5
  • Fri, Jan 22 2010 7:32 PM In reply to

    Re: Can a formula be written in excel or VBA to perform the "text to column" function ?

    On second thoughts, I would add a worksheet change event to C15-C42 to split it on entry.

    Regards

    Bob

    • Post Points: 21
  • Wed, Jan 27 2010 2:34 PM In reply to

    • WISHWELLS
    • Top 50 Contributor
    • Joined on Mon, Jan 18 2010
    • Posts 19
    • Points 303

    Re: Can a formula be written in excel or VBA to perform the "text to column" function ?

    Bob

    I would be interested in the more advanced way of attaining more dependent drop down menus, but would need to be able to re-create or add to the menu items esp next year when pricing or stocked items changes, so i would need to be able to understand the formula.

    Also the loop macro sounds good to me, but I may be in over my head so any help you are willing to share is greatly appreciated!

    Lynn

    • Post Points: 21
  • Wed, Jan 27 2010 5:11 PM In reply to

    Re: Can a formula be written in excel or VBA to perform the "text to column" function ?

    Lynn,

     

    Try this.

    Regards

    Bob

    • Post Points: 21
Page 1 of 3 (31 items) 1 2 3 Next > | RSS
Copyright Excel User Group and the relevant contributors, 2010. All Trade Marks acknowledged. This site is a peer-to-peer site and NOT affiliated in any way to Microsoft Corp. All rights reserved.