+ Reply to Thread
Results 1 to 22 of 22

Split text string into 5 columns

Hybrid View

  1. #1
    Forum Expert
    Join Date
    04-22-2013
    Location
    .
    MS-Off Ver
    .
    Posts
    4,418

    Re: Split text string into 5 columns

    @John,

    Have you tried it?

    Select Rows 11 to 16 and try running your code... your comment regarding the C-H is incorrect, it doesn't make any difference.

    with C11:H16 to selected,
    y = 11 and x = 6
    so your loop will go from 6 to 11 with -1 steps... which will just exit the loop instantly and do nothing.

    @Desree86, I do not use i in my code... so not sure why that is an error on that line. Have you tried this code:
    sub macro_1()
    dim i
    for i = selection.row to selection.row + selection.rows.count
       Range("D" & i) = mid(Range("C" & i),1,3)
       'and so on
    next
    end sub
    I've changed my variable to i to make mine and John's code more interchangeable.

  2. #2
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Split text string into 5 columns

    Quote Originally Posted by yudlugar View Post
    @John,

    Have you tried it?

    Select Rows 11 to 16 and try running your code... your comment regarding the C-H is incorrect, it doesn't make any difference.

    with C11:H16 to selected,
    y = 11 and x = 6
    so your loop will go from 6 to 11 with -1 steps... which will just exit the loop instantly and do nothing.

    @Desree86, I do not use i in my code... so not sure why that is an error on that line. Have you tried this code:
    sub macro_1()
    dim i
    for i = selection.row to selection.row + selection.rows.count
       Range("D" & i) = mid(Range("C" & i),1,3)
       'and so on
    next
    end sub
    I've changed my variable to i to make mine and John's code more interchangeable.
    I tested it. You have it inverted y = selection.row (the first row in the selection) - 6 , x = selection.rows.count (the last row in the selection) - 11. It loops from the bottom of the selection to the top.

+ 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. split string into multiple columns
    By bmccall17 in forum Excel General
    Replies: 8
    Last Post: 06-05-2015, 12:27 AM
  2. Advanced Split Function: Need to pull text string in quotes, within a text string
    By Zamboni in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-27-2013, 04:38 PM
  3. Split String into many columns according to Format criteria
    By wali in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-23-2010, 01:50 AM
  4. UDF to Split Text String
    By cdrhodes in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-28-2010, 03:40 PM
  5. Split text string to different columns
    By liarliar in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-04-2008, 09:13 AM

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