Consulting

Results 1 to 6 of 6

Thread: Solved: Text to Rows

  1. #1

    Solved: Text to Rows

    I am attaching an example of a evaluation results spreadsheet. Yesterday I received help, but after testing, determined that the VB script, although great, will not work for this particular situation. And of course I need help, again.

    Let me describe what is happening now. The VB script is separating multi-responses from one cell to individual responses in individual cells (responses separated with a ":") with a double click. Cells are added directly below the double clicked cell (multi-responses cell), Leaving the columns on the left and right unchanged.


    The problem, the responses are not associated with a role type. (Question 1 in the example spreadsheet).

    What is needed, once I double click on the multi-response cell, rows would be added, duplicating the information across the original row.

    Don't know if this can be done? But I have seen amazing things come from this site.

    This would allow us to see what users are actually doing and create more role specific training.

    Any help will greatly appreciated.

    Brenda

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    [vba]

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Dim ans
    Dim Cels As Long, i As Long
    Cancel = True
    ans = Split(Target, ":")
    Cels = UBound(ans)
    Target.Offset(1).Resize(Cels).EntireRow.Insert shift:=xlDown
    Rows(Target.Row).Copy Cells(Target.Row + 1, "A").Resize(Cels)
    For i = 0 To Cels
    Target.Offset(i) = ans(i)
    Next
    End Sub
    [/vba]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3

    Watch what you ask for

    OK, I know that I ask for all the rows to be copied down. But that is not working for management. I have worked on this some today, but cannot figure it out. The attached spreadsheet is working as far as separating the responses into separate rows, but all I really need to copy along with the response rows is column "T", that shows the role of the user. Example in attached spreadsheet. Columns AD, AI and AN shows where I double clicked and separated the responses. Column "T" is the example of copying the role type. Hope you can help.
    Thanks in advance
    Brenda

  4. #4
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    [VBA]Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
    Dim ans
    Dim Cels As Long, i As Long
    Cancel = True
    ans = Split(Target, ":")
    Cels = UBound(ans)
    Target.Offset(1).Resize(Cels).EntireRow.Insert shift:=xlDown

    'Just need column "T" to be copied down. Not entire row across.

    Cells(Target.Row, "T").Resize(Cels + 1).FillDown

    For i = 0 To Cels
    Target.Offset(i) = ans(i)
    Next
    End Sub[/VBA]
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  5. #5
    amazingly perfect, thanks

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    We aim to please!
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

Posting Permissions

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