New Contributor

# How to sort groups of numbers in rows to interleaved columns

Hi Folks

This has had me wracking my brain for a couple of days, so any suggestions hugely appreciated!

I have a sheet that looks in part like the following there's around 2000 rows, so looking a VBA snippet unless there's a funky sort I've not found

1

1

2

3

3

4

4

and I'm after it looking like

1234

134

1234

3 Replies

# Re: How to sort groups of numbers in rows to interleaved columns

@Adrian Watkins , what's the logic of the grouping? I can't see a pattern just by looking at the example.

# Re: How to sort groups of numbers in rows to interleaved columns

@TheAntony thanks for the reply! sorry, it’s repeated groups of up to 1-4 sorted numerically, so they are like 111222333444 but some groups may skip some numbers, so min of one number, max of four and results have to be in numeric order 1234 with no gaps for skipped ones. Full job is combining a series of worksheets that were done by row when they should have been column as source for a mail merge

# Re: How to sort groups of numbers in rows to interleaved columns

If your version of Excel supports dynamic arrays, and if I understood the logic correctly, you may add helper column

with formula

``=--CONCAT(UNIQUE(MID(A1,SEQUENCE(1,LEN(A1)),1),1))``

and sort by it.