sets of data

JGarza

Board Regular
Joined
Mar 26, 2002
Messages
93
I have a listing of approximately 20,000 account numbers in a column in a spreadsheet.

What i need is to combine account numbers into one cell in sets of 1000. How can i do this automatically with a macro or something. They also need to be seperated with a semi-colon for example (138585;385020;3059093;2323;4802084098;9398...)

I'm not VBA savy, so i hope for a simple formula.

Thanks
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Max cell length for a cell is 32767 characters, with only 1028 being able to be displayed (at least prior to excel 2007). Your account numbers seem to be up to 10 characters + semicolon * 1000, or 11,000 characters which is a lot (but potentially doable).

However, since you can't use CONCATENATE() or & in array formulas, there will be no easy formula solution. You will likely have to look into VBA or a non-formula solution.

Assuming all your account numbers are in column A from A1:A20000 or so, here's code that will work:
Code:
Sub Test()
    Dim i As Integer
    Dim j As Integer
    Dim k As Integer
    Dim strAccounts As String
    
    k = 1
    
    For i = 1 To Worksheets("Sheet1").Range("A1").End(xlDown).Row
        If j = 1000 Then
            j = 0
            Cells(k, 2).Value = strAccounts
            strAccounts = ""
            k = k + 1
        Else
            strAccounts = strAccounts & Cells(i, 1).Value & ";"
            j = j + 1
        End If
    Next i
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,203,467
Messages
6,055,589
Members
444,800
Latest member
KarenTheManager

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top