+ Reply to Thread
Results 1 to 4 of 4

VBA Code to Split a cell value into 2 or more cells

  1. #1
    Registered User
    Join Date
    03-19-2013
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    11

    VBA Code to Split a cell value into 2 or more cells

    Hi,

    I have a value in a cell(say A1 cell) => "This is a versatile macro" and i want this cell value to be splitted in 5 rows like
    This
    is
    a
    versatile
    macro

    How could i do this?

    Please help guyz

    Refer the attached excel
    Attached Files Attached Files
    Last edited by SaurabhShri1; 03-21-2013 at 08:36 AM.

  2. #2
    Registered User
    Join Date
    03-21-2013
    Location
    Toulouse, France
    MS-Off Ver
    Excel 2007
    Posts
    3

    Re: VBA Code to Split a cell value into 2 or more cells

    I think you could do something like this:

    Please Login or Register  to view this content.
    and the Main function

    Please Login or Register  to view this content.
    You may need to debug this, because I do not have an Excel on my current laptop. Especially the Instr sentence, because I sometimes make mistake using it (I often put parameters 2 & 3 in the bad order).

    Hope it will helps.
    Last edited by Grizar; 03-21-2013 at 01:58 PM.

  3. #3
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: VBA Code to Split a cell value into 2 or more cells

    This can be done with formulas, but if you really need a macro, it can be done as a one-liner:
    Please Login or Register  to view this content.
    Hope that helps,
    ~tigeravatar

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Forum Expert tigeravatar's Avatar
    Join Date
    03-25-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2003 - 2013
    Posts
    5,361

    Re: VBA Code to Split a cell value into 2 or more cells

    To make the macro more versatile, this version will prompt first for the string to split, and second for the user to select the output destination starting cell:
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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