Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How do I macro sort with a varaible range (differing last cell)?

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).
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default How do I macro sort with a varaible range (differing last cell)?

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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default How do I macro sort with a varaible range (differing last cell)?

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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to sort variable data range fails Kiwipingu Excel Discussion (Misc queries) 1 June 3rd 10 10:16 PM
Sorting by rows with differing numbers of cell entries DayleMSCU Excel Discussion (Misc queries) 3 March 17th 10 03:30 PM
Macro to Sort A-Z a variable range of cells Keith B Excel Discussion (Misc queries) 1 September 9th 09 03:31 AM
Hyperlink varaible substitution - How To Sledge Bacon Excel Worksheet Functions 10 May 29th 08 06:03 PM
macro code to sort a range ashish128 Excel Discussion (Misc queries) 5 August 17th 06 05:52 PM


All times are GMT +1. The time now is 05:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"