ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   New Users to Excel (https://www.excelbanter.com/new-users-excel/)
-   -   Variable Column Sort (https://www.excelbanter.com/new-users-excel/124092-variable-column-sort.html)

Bernie

Variable Column Sort
 
I need to aIphabetize columns with a set start column, but a variable
range for the end column.


Thanks,
Bern


Gary''s Student

Variable Column Sort
 
The following starts in column B (2). It asks for the last column number and
will then individually sort each column between column 2 and the supplied
column number:

Sub gsnu()
n = Application.InputBox("enter last column number to be sorted:", 1)
For i = 2 To n
Columns(i).Sort Key1:=Cells(1, i)
Next
End Sub

--
Gary's Student


"Bernie" wrote:

I need to aIphabetize columns with a set start column, but a variable
range for the end column.


Thanks,
Bern




All times are GMT +1. The time now is 07:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com