Results 1 to 7 of 7

Convert Column Into Comma-Separated List: Getting Around Character Limit

Threaded View

  1. #1
    Registered User
    Join Date
    05-09-2012
    Location
    USA
    MS-Off Ver
    2019 16.0.13205.200000 64-bit
    Posts
    61

    Convert Column Into Comma-Separated List: Getting Around Character Limit

    Hey, guys!

    I'm struggling with a little challenge. I have a list of entries in Column A, in each cell there are 2-3 words, around 17 000 rows in whole column, and 160 000 characters in whole column. I need to take each cell in Column A and put them into a comma-separated list.

    So if Column A looks like this:
    Cow
    Apple
    Cider
    Banana

    I need a macro that would make it into: Cow, Apple, Cider, Banana

    I found the following macro online:
    Sub generatecsv()
    
          Dim dataRow As Integer
          Dim listRow As Integer
          Dim data As String
    
          dataRow = 1: Rem the row that it is being read from column A otherwise known as 1 in vb script
          listRow = 1: Rem the row in column B that is getting written
    
          Do Until Cells(dataRow, 1).Value = "" And Cells(dataRow + 1, 1).Value = ""
            If (data = "") Then
              data = Cells(dataRow, 1).Value
            Else
              If Cells(dataRow, 1).Value <> "" Then
                data = data & "," & Cells(dataRow, 1).Value
              Else
                Cells(listRow, 2).Value = data
                data = ""
                listRow = listRow + 1
              End If
            End If
            dataRow = dataRow + 1
          Loop
    
          Cells(listRow, 2).Value = data
    
        End Sub
    It stores resulting list in a cell (B1). The problem is that since I have more than 160 000 characters in the column, it exceeds Excel's cell character limit of 32 767.
    Is there way to store result in clipboard maybe or some other workaround?
    Last edited by splendidus; 08-14-2020 at 10:41 AM.
    Office 2019 16.0.13205.200000 64-bit

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to lookup a value in one column to create a comma separated list
    By powersml07 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-05-2018, 02:16 PM
  2. Replies: 5
    Last Post: 06-29-2016, 01:27 PM
  3. Help Creating a comma separated list based on a specific column
    By zach.shupp in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-21-2014, 09:44 PM
  4. Replies: 3
    Last Post: 09-25-2014, 02:14 PM
  5. Programatically Convert comma separated 'Text to Column'
    By super_duper_guy in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-01-2012, 08:04 PM
  6. Convert range of cells to comma separated list
    By maw230 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-23-2012, 06:03 PM
  7. Going from column to comma separated list...
    By jmboggiano in forum Excel General
    Replies: 1
    Last Post: 03-10-2005, 01:06 PM

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