Results 1 to 3 of 3

Parse Text, Split to New Row, Multiple Columns

Threaded View

msbaker Parse Text, Split to New Row,... 06-29-2010, 04:31 PM
rylo Re: Parse Text, Split to New... 06-29-2010, 06:57 PM
foxguy Re: Parse Text, Split to New... 06-30-2010, 02:01 PM
  1. #2
    Forum Expert
    Join Date
    01-15-2007
    Location
    Brisbane, Australia
    MS-Off Ver
    2007
    Posts
    6,591

    Re: Parse Text, Split to New Row, Multiple Columns

    Hi

    See how this goes.

    Sub aaa()
      Dim i As Long, j As Integer, resizelen As Integer, curlen As Integer
      resizelen = 1
      Columns("A:A").ColumnWidth = 12
      Columns("B:B").ColumnWidth = 1.5
      Columns("C:C").ColumnWidth = 10
      Columns("D:D").ColumnWidth = 1.5
      Columns("E:E").ColumnWidth = 46.5
      Columns("F:F").ColumnWidth = 1.5
      Columns("G:G").ColumnWidth = 34.5
      Columns("H:H").ColumnWidth = 1.5
      Columns("I:I").ColumnWidth = 15.5
      Columns("J:J").ColumnWidth = 1.5
    
      
      Application.DisplayAlerts = False
      For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
        Cells(i + 1, 1).Resize(resizelen, 1).EntireRow.Insert shift:=xlDown
        For j = 1 To 5
          
          curlen = Round(Len(Cells(i, j)) / Cells(i, j).ColumnWidth, 0)
          If curlen > resizelen Then
            Cells(i, 1).Offset(resizelen + 1, 0).Resize(curlen - resizelen, 1).EntireRow.Insert shift:=xlDown
            resizelen = curlen
          End If
          Cells(i, j).Justify
        Next j
      Next i
      Application.DisplayAlerts = True
      
      For i = Cells(Rows.Count, 1).End(xlUp).Row To 1 Step -1
        If IsEmpty(Cells(i, 1)) And Cells(i, 1).End(xlToRight).Column = Columns.Count Then 'ie it is a blank line
          Cells(i, 1).EntireRow.Delete
        End If
      Next i
    End Sub
    rylo
    Last edited by rylo; 06-29-2010 at 07:50 PM. Reason: reworked to automate the resize length variable

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