Split and validate form textbox input

  • Hello!


    I am trying to put together an idiotproof way of inputting data and VBA is not my real forte.


    I have a block of text that is copied into a textbox and then when the button is pressed I want the text to start appearging in cell A1 and then be split appropriately. I am using the following code which splits the rows based on a linebreak in the textbox entry :



    However I want to modify it so that it does slightly more, namely :


    1. Where there is a tab in the input text, it splits the data into the next column
    2. Where there is a line break in the input text, it splits the data into the next row
    3. Validates so that if the first word is not "Bob" then it throws an error



    Sample data would be eg :


    Bob Kate Fred
    Jane Eric Terry
    Simon Andrew Flora



    So that it would appear as :


    [TABLE="class: grid, width: 200"]

    [tr]


    [td]

    Bob

    [/td]


    [td]

    Kate

    [/td]


    [td]

    Fred

    [/td]


    [/tr]


    [tr]


    [td]

    Jane

    [/td]


    [td]

    Eric

    [/td]


    [td]

    Terry

    [/td]


    [/tr]


    [tr]


    [td]

    Simon

    [/td]


    [td]

    Andrew

    [/td]


    [td]

    Flora

    [/td]


    [/tr]


    [/TABLE]



    where the number of input lines is variable . Hope that this makes sense!

  • Re: Split and validate form textbox input


    Can you upload a sample workbook with the sample data already in one cell so that I can test with the appropriate characters, line feeds, carriage returns, whatever the case may be, already in place.


    When you click reply there will be a new button labeled go advanced, click on that button then there will be a paperclip icon in the toolbar, click on that icon and follow the instructions.

    Bruce :cool:

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!