+ Reply to Thread
Results 1 to 12 of 12

Comma delimited list cell to new row code help

Hybrid View

  1. #1
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: Comma delimited list cell to new row code help

    Hi John

    In this code
    Sub CountCommas()
        Sheets("Expanded").Select
        daRow = Application.CountA(ActiveSheet.Range("A:A"))
        For Z = 1 To daRow              'How many rows to work on
            daSting = Cells(Z, 1)       'Get string
            stringLen = Len(daSting)        'Length of String
            For X = 1 To stringLen          'Increment thru
                Select Case Mid(daSting, X, 1)
                Case ","                'If it is a comma
                    daAnsw = daAnsw + 1    'Add 1 to list
                Case Else           'Do nothing
                End Select
            Next
            Cells(Z, 25) = daAnsw            'Write the answer
            daAnsw = 0                      'Reset counter
        Next
        Call InsertRows
    End Sub
    In the file that works, daRow evaluates to 15 and all your coma delimited cells are within that range...so it works. In the file that doesn't work, daRow evaluates to 87 and all the coma delimited cells fall outside that range and aren't getting evaluated.

    Welcome to the Forum!
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  2. #2
    Registered User
    Join Date
    07-07-2011
    Location
    tx
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Comma delimited list cell to new row code help

    Quote Originally Posted by jaslake View Post

    In the file that works, daRow evaluates to 15 and all your coma delimited cells are within that range...so it works. In the file that doesn't work, daRow evaluates to 87 and all the coma delimited cells fall outside that range and aren't getting evaluated.
    Thank you for your answer. How would I get daRow to encompass all of the delimited cells? Really, it needs to be able to encompass a variable amount of rows since they change almost daily, how would you go about accomplishing that? I am pretty new to writing code, so I apologize if that is a silly question. Thanks again for your time.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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