![]() |
#1
|
|||
|
|||
![]()
I have an array of about 340 columns wide and 16 rows long. I need to sort (ascending) each column separately (select column, sort a-z, continue with current selection). It will be quite tedious to do the sorting manually for 340 columns, so I was looking to build a macro to do it for me.
I've tried the following, but can't get it debugged. Of course then I also need to add in a loop to go to the next column, repeat, and eventually end the loop when out of columns with content to sort. Any help in creating the macro will be appreciated, else I'm back to just doing each column manually. Thanks in advance, Andrew Sub DoIt() ActiveWorkbook.Worksheets("SortIt").Sort.SortField s.Clear ActiveWorkbook.Worksheets("SortIt").Sort.SortField s.Add Key:=Range(ActiveCell.EntireColumn.Cells(1)), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("SortIt").Sort .SetRange Range(Selection.EntireColumn) .Header = xlGuess .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With End Sub |
Tags |
macro, sorting columns |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
.pdf to .xlsx - How to get sort-able columns? | CCinPA | Excel | 0 | 07-05-2016 08:30 AM |
![]() |
Dave Fraser | Excel | 2 | 06-06-2014 11:48 AM |
Need help sorting data in columns that will sort by number of Xs | brenna.at.work | Excel | 8 | 04-12-2014 07:00 AM |
quick replace, sort, change columns | userman | Excel | 1 | 05-01-2012 06:24 AM |
![]() |
Bahir Barak | Word | 2 | 01-20-2011 01:52 PM |