+ Reply to Thread
Results 1 to 4 of 4

Is there a way to use VBA code to take data in a cell and create a new row (TXT to ROW?)

Hybrid View

Mustangs Is there a way to use VBA... 11-12-2013, 07:47 PM
protonLeah Re: Is there a way to use VBA... 11-12-2013, 08:09 PM
Mustangs Re: Is there a way to use VBA... 11-13-2013, 06:26 PM
berlan Re: Is there a way to use VBA... 11-12-2013, 08:56 PM
  1. #1
    Registered User
    Join Date
    11-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Is there a way to use VBA code to take data in a cell and create a new row (TXT to ROW?)

    Hello everyone. I have some data that has a uniquie identifyer by row but populated one cell within that row with multiple employee 's that I would like have its own row. Is there a formula or setting I can utilize? Or is VBA my only option. See attached WKP for example.

    Cheers!
    Attached Files Attached Files

  2. #2
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    Win10/MSO2016
    Posts
    13,051

    Re: Is there a way to use VBA code to take data in a cell and create a new row (TXT to ROW

    Try text-to-columns:
    Select delimited,
    Select Delimiters Space & other
    in the other box type Alt+0010 (i.e. new line character)
    Hit Next and choose "text" for each column
    Ben Van Johnson

  3. #3
    Registered User
    Join Date
    11-12-2013
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    10

    Thumbs up Re: Is there a way to use VBA code to take data in a cell and create a new row (TXT to ROW

    Quote Originally Posted by protonLeah View Post
    Try text-to-columns:
    Select delimited,
    Select Delimiters Space & other
    in the other box type Alt+0010 (i.e. new line character)
    Hit Next and choose "text" for each column


    WORKED GREAT! Thanks so much!

  4. #4
    Forum Expert
    Join Date
    02-22-2013
    Location
    London, UK
    MS-Off Ver
    Office 365
    Posts
    1,218

    Re: Is there a way to use VBA code to take data in a cell and create a new row (TXT to ROW

    Great suggestion protonLeah!

    Mustangs, you could also use the VBA split function to get each employee number on a unique row:

    Sub myMacro()
    
        Dim Rng As Range, c As Range
        Dim cLines As Variant
        Dim i As Long, j As Long
        Dim count As Long
    
        With Sheet1
            Set Rng = .Range(.Range("B2"), .Range("B2").End(xlDown))
            lRows = Rng.Rows.count
            For Each c In Rng.Cells
                cLines = Split(c.Value, vbLf)
                count = count + UBound(cLines) + 1
            Next c
            For i = 1 To count
                cLines = Split(Rng.Cells(i, 1).Value, vbLf)
                For j = LBound(cLines) To UBound(cLines)
                    If j = 0 Then
                        Rng.Cells(i, 1) = CLng(cLines(j))
                    Else
                        .Rows(Rng.Cells(i + j, 1).Row).Insert Shift:=xlDown
                        Rng.Cells(i + j, 1) = CLng(cLines(j))
                    End If
                Next j
            Next i
        End With
        Set Rng = Nothing
    
    End Sub

+ 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. Trying to create code that selects part of a cell and does a strikethrough
    By jrortiz in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-12-2013, 01:31 AM
  2. VBA Code To Create Sheet of Data From Other Worksheets.
    By kozman2 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-24-2013, 11:40 AM
  3. Replies: 1
    Last Post: 11-13-2012, 02:06 PM
  4. How do you create an alpha numeric code using data from other cells
    By jxking in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 12-15-2010, 11:24 AM
  5. vba code to create a list from data in one field
    By short_n_curly in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-10-2007, 11:16 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