I use Excel 2007, but this particular file I save in xls. format because I distribute it to others. If the code just works for 2007 that's fine. I can just save the file in an earlier format before I distribute it.
I use Excel 2007, but this particular file I save in xls. format because I distribute it to others. If the code just works for 2007 that's fine. I can just save the file in an earlier format before I distribute it.
Hi mannuhs
Sort syntax is different for Excel 2007. This syntax will work in either. You indicated to sort through Column O but your Data extends to Column R so that's what I used. If you truly want Column O change the rng references.
Let me know of issues.
![]()
Option Explicit Sub SortStuff() Dim LR As Long, piRow As Long, CERow As Long, VOSRow As Long Dim ws As Worksheet Dim rng As Range Set ws = Sheets("Sheet1") With ws LR = .Cells.Find("*", .Cells(.Rows.Count, .Columns.Count), SearchOrder:=xlByRows, _ SearchDirection:=xlPrevious).Row piRow = .Columns("A").Find(what:="P1 Level Calls", LookIn:=xlValues, lookat:=xlWhole).Row CERow = .Columns("A").Find(what:="Vendor CE Meet", LookIn:=xlValues, lookat:=xlWhole).Row VOSRow = .Columns("A").Find(what:="Vendor On Site", LookIn:=xlValues, lookat:=xlWhole).Row Set rng = .Range(.Cells(piRow + 1, 1), .Cells(CERow - 5, "R")) With rng If rng.Rows.Count > 1 Then .Sort Key1:=.Cells(piRow + 1, "J"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal End If End With Set rng = .Range(.Cells(CERow + 1, 1), .Cells(VOSRow - 1, "R")) With rng If rng.Rows.Count > 1 Then .Sort Key1:=.Cells(CERow + 1, "J"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal End If End With Set rng = .Range(.Cells(VOSRow + 1, 1), .Cells(LR, "R")) With rng If rng.Rows.Count > 1 Then .Sort Key1:=.Cells(VOSRow + 1, "J"), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ DataOption1:=xlSortNormal End If End With End With End Sub
John
If you have issues with Code I've provided, I appreciate your feedback.
In the event Code provided resolves your issue, please mark your Thread as SOLVED.
If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.
Wow that worked perfect! Thanks so much!
You're welcome...glad I could help.
If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.
Thanks.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks