Results 1 to 10 of 35

Thread: Redistribute a Delimited Column Of Data into Separate Rows (Keeping Other Data As Is)

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    Trouble with this Macro

    I'm trying to apply this macro to a spreadsheet that I have, but I'm having some issues. I keep getting a run time error. I've attached the file so that you can see what I'm working on.

    Thanks for any help that you can lend!
    Attached Files Attached Files

  2. #2
    Junior Member
    Join Date
    May 2013
    Posts
    6
    Rep Power
    0
    Trosko, you are having the same issue that I faced, your deliminated column "L" has some blanks so the code errors out. I removed the rows with blanks in column L and the macro ran just fine.

    So you'll need to update the macro to account for this. I wasn't able to figure that part out and in my case it didn't matter, rows with blanks in the deliminated column were not needed for my project so I was able to just delete those rows by inserting the following code in the macro. You'll notice I put the new code right after the delclarations and before the existing code.

    Code:
    Sub RedistributeData()
      Dim X As Long, LastRow As Long, A As Range, Table As Range, Data() As String
      Const Delimiter As String = ", "
      Const DelimitedColumn As String = "D"
      Const TableColumns As String = "A:D"
      Const StartRow As Long = 2
      
    Columns(4).SpecialCells(xlCellTypeBlanks).EntireRow.Delete
    Last edited by Excel Fox; 08-18-2013 at 08:41 PM. Reason: Code tag added

  3. #3
    Junior Member
    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    That worked great, but...

    Quote Originally Posted by msrebraca View Post
    Trosko, you are having the same issue that I faced, your deliminated column "L" has some blanks so the code errors out. I removed the rows with blanks in column L and the macro ran just fine.

    So you'll need to update the macro to account for this. I wasn't able to figure that part out and in my case it didn't matter, rows with blanks in the deliminated column were not needed for my project so I was able to just delete those rows by inserting the following code in the macro. You'll notice I put the new code right after the delclarations and before the existing code.
    The modification worked great, but is there an easy to autofill the blanks with a value like "Null" rather than delete them?

  4. #4
    Junior Member
    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    One more thing...

    Things seem to go a little "wonky" when I hit 1179 rows - the macro still separates the rows, but it stops copying the information. Anyone have any idea why that might happen? Thanks!

  5. #5
    Junior Member
    Join Date
    May 2013
    Posts
    6
    Rep Power
    0
    You can select the range of cells in question and then use ctrl+F and the Replace All function to look for blanks and replace with NULL. Then run the original macro without the code that deletes the blanks.

  6. #6
    Junior Member
    Join Date
    Jul 2013
    Posts
    4
    Rep Power
    0

    Red face

    Quote Originally Posted by msrebraca View Post
    You can select the range of cells in question and then use ctrl+F and the Replace All function to look for blanks and replace with NULL. Then run the original macro without the code that deletes the blanks.
    Thanks! I knew there would be something really easy that I wasn't thinking of.

Similar Threads

  1. Move data from rows into columns for every unique value
    By mahmoud-lee in forum Excel Help
    Replies: 4
    Last Post: 06-13-2013, 03:02 AM
  2. Replies: 4
    Last Post: 05-01-2013, 09:49 PM
  3. Replies: 3
    Last Post: 03-16-2013, 05:13 PM
  4. Replies: 12
    Last Post: 08-19-2012, 06:17 PM
  5. Transpose data into Rows
    By vikash200418 in forum Excel Help
    Replies: 2
    Last Post: 04-10-2012, 11:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •