PC Review


Reply
Thread Tools Rate Thread

How do I macro sort with a varaible range (differing last cell)?

 
 
=?Utf-8?B?c3V0aWJ1c2Fu?=
Guest
Posts: n/a
 
      7th Nov 2007
I need to sort from A3 to J100, for example, now. Later, it could be from A3
to J207. There usually are blank columns also (the LIST command didn't like
that).
 
Reply With Quote
 
 
 
 
Dave Peterson
Guest
Posts: n/a
 
      7th Nov 2007
Can you pick out a column that always has data in it if that row is used?

Maybe...

Dim LastRow as long
with worksheets("somesheetname")
lastrow = .cells(.rows.count,"A").end(xlup).row

.range("a3:J" & lastrow).sort ...rest of sort parms here...
End with

sutibusan wrote:
>
> I need to sort from A3 to J100, for example, now. Later, it could be from A3
> to J207. There usually are blank columns also (the LIST command didn't like
> that).


--

Dave Peterson
 
Reply With Quote
 
=?Utf-8?B?RlN0MQ==?=
Guest
Posts: n/a
 
      7th Nov 2007
hi
find the last row.
dim r as range
lr = cells(Rows.Count, "A").End(xlUp).Row
set r = range("A3:J" & lr)
r.Sort Key1:=Range("A3"), _ 'or what you have
Order1:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal

regards
FSt1

"sutibusan" wrote:

> I need to sort from A3 to J100, for example, now. Later, it could be from A3
> to J207. There usually are blank columns also (the LIST command didn't like
> that).

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select range from a varaible Excel User Microsoft Excel Programming 5 5th Jan 2009 03:58 PM
macro to select range from active cell range name string aelbob Microsoft Excel Programming 2 14th Jul 2008 09:19 PM
macro code to sort a range ashish128 Microsoft Excel Misc 5 17th Aug 2006 05:52 PM
How to sort 1 cell range keeping other range same kamploops Microsoft Excel Misc 1 24th Aug 2004 09:32 PM
Macro to sort a range in ascending order Kerrick Sawyers Microsoft Excel Worksheet Functions 1 13th Feb 2004 02:04 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:39 AM.