sorting

C

Curt

is there a way to sort by cells in a column also can you repeat the search
after first group are reached. column has many groups of numbers want to
group by 1 to 4 repeated. have not been able to get it to sort allways puts
all 1s 2s together. Want a 1234 group.
Anyone? I'm beat
thanks
[email protected]
 
E

excelent

some like this:
sort data in C2:C100 in step of 4 cells

Sub tst()
Dim t
For t = 2 To Cells(100, 3).End(xlUp).Row Step 4
Range(Cells(t, 3), Cells(t + 3, 3)).Select
Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
Next
End Sub


"Curt" skrev:
 
C

Curt

Better explain of problem.
Have entries in column d First to sort out are A B C D These will go to top.
Remainder are nbrs 1 thru 8 Need to sort in groups of 8 as 1 to 8. Never
tried this befor don't know if possible. Learning new tricks at my age is
fun. Trying to help a parade committee of Vets which I am a part of.
All help is greatly appreciated.
[email protected]
 
D

Dave Peterson

DataOption# was added in xl2002.

If you don't use xl2002+, then delete that parm and its value:

Selection.Sort Key1:=Range("C2"), Order1:=xlAscending, Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom
 
D

Dave Peterson

It looks like it should work if you re-run it.

How do you know it's not running a second time--maybe the data is already sorted
correctly??????
 
D

Dave Peterson

This line would only sort the first 100 rows (maximum 100 rows).

For t = 2 To Cells(100, 3).End(xlUp).Row Step 4

Maybe

For t = 2 To Cells(rows.count, 3).End(xlUp).Row Step 4


i did a sort with excel it sorted as usual 1,s 2s, etc tried macro again it
would not resort to 1234
 
D

Dave Peterson

There is no selection.sortkey1

You'll want to copy and paste from the other workbook's project (or from the
newsgroup posting)--but retyping is where lots of typos can arise.
 
Top