![]() |
![]() |
|
|||||||
| Excel Questions All Excel/VBA questions - formulas, macros, pivot tables, general help, etc. Please post to this forum in English only. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
New Member
Join Date: Mar 2002
Posts: 13
|
How do I write code to sort on the last column in a range? Im using:
range(activecell,activecell.end (xltoright).end(xldown)).select for the range. Then I need to sort on the last column in the range (changes Weekly). Thanks in advance Wrecker |
|
|
|
|
|
#2 |
|
Board Regular
Join Date: Feb 2002
Location: Brisbane, Down Under
Posts: 533
|
I changed your code slightly and it worked - probaly cleaner and better soultions out there
Range(ActiveCell.End(xlToRight), ActiveCell.End(xlToRight).End(xlDown)).Select |
|
|
|
|
|
#3 |
|
Board Regular
Join Date: Apr 2002
Location: Cape Town,South Africa
Posts: 234
|
My one is bsically similar to the above answer.But,see if it works for you
Range(ActiveCell.End(xlToRight), ActiveCell.End(xlToRight).End(xlDown)).Select |
|
|
|
|
|
#4 |
|
New Member
Join Date: Mar 2002
Posts: 13
|
I have the code to select the range. I need the code to sort on the last column in the range.
Thanks Wrecker |
|
|
|
|
|
#5 | |
|
Board Regular
Join Date: Mar 2002
Posts: 1,805
|
Quote:
A simple code to sort last column of current range: Sub SortLastColumn() Dim myRange As Range, myCol As Integer, sortCol As String Set myRange = ActiveCell.CurrentRegion myCol = myRange.Columns.Count sortCol = myRange.Item(1, myCol).Address myRange.Select Selection.Sort Key1:=Range(sortCol), Order1:=xlAscending, Header:=xlGuess, _ OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _ IgnoreControlCharacters:=True, IgnoreDiacritics:=True End Sub Eli |
|
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
| Display Modes | |
|
|