ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Variable sorting (https://www.excelbanter.com/excel-programming/425526-variable-sorting.html)

Graham H

Variable sorting
 
In Excel 2003 I have a range A15 to U500. In column B there will be either the text value
P or S. I want to do a sort on the range which will involve 4 criteria. To achieve this I
want to sort column B to order the P and S. I then want to select the rows with P and sort
by the three other criteria. I then need the rows below these with S and sort by the same
criteria. I have a schematic below of what I was trying but my problem is in selecting the
row range or how best to do it. eg below I was trying-- rows ("15:14+a").select ---but
this is obviously not the way to do it. There may be and probably is a better way to do
the whole thing but I would value any help.

Sub sorting()
Dim n As Integer
a = 0
For n = 15 To 500
If Cells(n, 2) 0 Then
a = a + 1
End If
Next
How to get this to work "select rows 15 to 14+a" <<<<<<<<

'<< selection sort by column 2 I can do this
b = 0
For n = 15 To 500
If Cells(n, 2) = "P" Then
b = b + 1
End If
Next
How to get this to work "select rows 15 to 14+b" <<<<<<<<

'<< selection sort by columns 3 7 and 8 I can do this
How to get this to work "select rows 15+b to 14+a" <<<<<<<<

'<< selection sort by columns 3 7 and 8 I can do this
End Sub

Graham

Bernd P

Variable sorting
 
Hello Graham,

I suggest to take mu UDF GSort:
www.sulprobil.com

Regards,
Bernd


All times are GMT +1. The time now is 01:37 PM.

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