+ Reply to Thread
Results 1 to 2 of 2

Text to rows and copy rows.

  1. #1
    Registered User
    Join Date
    06-30-2011
    Location
    Pittsburgh, pennsylvania
    MS-Off Ver
    Excel 2010
    Posts
    1

    Text to rows and copy rows.

    I'm not completely sure if I am dreaming too big here, so please let me know if my idea is a bit ludiculous.

    I have a spreadsheet that contains two columns (columns "O" and "P") with serial numbers in them. The serial numbers in these two columns are separated by commas.

    I wrote some script to calculate how many commas are in these last two columns. I stored this number in a variable named 'commas' as such.

    Lastcell = Cells(Rows.Count, "O").End(xlUp).Row
    For i = Lastcell To 1 Step -1
    If (Cells(i, "O").Value) <> "" And Rows(i).EntireRow.Hidden = False_ Then
    commas = Len(Cells(i, "O").Value) - Len(Replace(Cells(i, "O").Value, ",", ""))

    So, I have my 'commas' variable. What I would like to do is perform a "text to rows" sorta deal. I'm trying to give each serial number its own unique row but have it contain the same information as the columns that come before it. The comma would be used as my delimiter in this particular case.

    This process needs to be performed for column "O" first then column "P."

    So the gist of it, each serial number (in column "O") gets its own row, and the information stored in columns 'A' through 'N' is right there with it. Then this process needs repeated for column 'P' whilst preserving the the information in columns 'A' through 'N' again.

    Needless to say, any help would be greatly appreciated. If any clarification is needed please say so.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,721

    Re: Text to rows and copy rows.

    Here's a quick take, if it's still not clear then I might be able to find time to do more.

    First, forum rules require code to be enclosed in "code" tags. Please see my signature below for instructions.

    Look up the function SPLIT. It will take the list of serial numbers and put each serial number into an array element. Then you repeatable can copy and insert the row, looping through the array to insert the next serial number.

    Your description says there are two columns with serial numbers, but your code only shows one column, so I'm not quite sure how you're handling that.

    BTW that's a clever way to count the commas.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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