Advanced Sorting (4000 rows) followup Q.

  • Thread starter Thread starter Tina Johnson
  • Start date Start date
T

Tina Johnson

Green John blue cats $50.00 Happy
Green 2 John blue cats $50.00
Green 2 blue John cats $50.00
Green 2 blue cats John $50.00
Green 2 blue cats $50.00 John

What I want: For example, I want "John" to be sorted to
the first column for each row.

Problem: In my original table, there are over 20+ Columns
and 4,000 rows. Sorting by row, three at at time would
take forever, especially since I have over 100 different
databases that I need to do this on.

Without sorting by rows three at a time, what's the best
solution? If there's no way to do this in excel without a
tedious process, is there another software solution
anyone is aware of?

Many thanks. Happy Holidays!

Tina :-)
 
If I sort each row separately in descending order, I can get John in the first
column:

John Happy Green cats blue $50.00
John Green cats blue $50.00 2
John Green cats blue $50.00 2
John Green cats blue $50.00 2
John Green cats blue $50.00 2


Is this what you want or do you have a specific custom order?

If it's what you want, you could try this macro:

Option Explicit
Sub testme01()

Application.ScreenUpdating = False

Dim myRow As Range

For Each myRow In ActiveSheet.UsedRange.Rows
With myRow
.Sort Key1:=.Cells(1), Order1:=xlDescending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlLeftToRight, _
DataOption1:=xlSortNormal
End With
Next myRow

Application.ScreenUpdating = True

End Sub

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm

Short course:
Hit alt-f11 to get to the VBE (where macros/UDF's live)
hit ctrl-R to view the project explorer
Find your workbook.
should look like: VBAProject (yourfilename.xls)

right click on the project name
Insert, then Module
You should see the code window pop up on the right hand side

Paste the code in there.

Now go back to excel.
Select your range of cells
click on Tools|macro|macros...
click on the macro name (testme01--but you could give it more meaningful name)
and then click run.
 
Back
Top