Consulting

Results 1 to 8 of 8

Thread: Solved: Excel - Text to rows

  1. #1

    Smile Solved: Excel - Text to rows

    I have a questionnaire that end users are completing. A few of the questions are multiple choice and they can choose as many of the responses that applies. The problem is, the application that pulls the data, puts all the responses in one cell divided with a colon. This makes it very difficult to calculate responses. Is there a way to extract these responses individually and insert a new cell(s) below the original in the same column without overwriting the data. There can be one response or 8 responses. See Attached example. column AO row 7, column AU, row 6. Thanks in advance for any help. (I have not been on VBA for awhile, feels good to be back)
    Brenda

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Can you post a "desired result" sample?
    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'

  3. #3
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Try this.
    Paste the code in the worksheet module. Doubleclick the multi-answer cell.
    EDIT: You'll need to turn off the Autofilter to allow insertion of cells.
    [vba]
    Option Explicit
    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).Insert shift:=xlDown
    For i = 0 To Cels
    Target.Offset(i + 1) = 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'

  4. #4
    Not sure what I am doing wrong, but it does not seem to work for me. URGH!!!!!!!!!!

  5. #5
    Thanks mdmackillop, not sure what I am doing wrong. see attached
    brenda

  6. #6
    Administrator
    VP-Knowledge Base VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Try this
    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'

  7. #7
    Man, you are very very good.

  8. #8
    VBAX Newbie
    Joined
    Feb 2013
    Posts
    1
    Location

    I need the same thing

    hello

    I need the exact same thing I think - I am very new to VBA - would it be possible to have a copy of your working example?
    thank you, thank you in advance

Posting Permissions

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