Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
ScottPcola
 
Posts: n/a
Default Sort Macro to Exclude Blank Rows?

My worksheet consists of some fairly straight forward columns and I have
built macros with assigned Command Buttons to sort by their relative column.

This worksheet is a master worksheet of which copies are distributed to
several sales reps that will have varying numbers of rows that they will
populate but no more than 200 rows.

My intent is to modify my Macros so that they do not include blank rows in
the sorting - (i.e. if a sales reps' sheet only contains 175 rows, I always
want the blank rows (176-200) to remain at the bottom.

Here is an example of one of my sorting macros for one of the columns:

Sub Sort_Rank()
Range("A10:V210").Select
Selection.Sort Key1:=Range("A10"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

I should point out that the range only includes the rows and columns of data
- it does not include column headers

Thanks for your help in advance,

Scott

  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Dave Peterson
 
Posts: n/a
Default Sort Macro to Exclude Blank Rows?

Can you pick out a column that's always used if that row is used?

I'm gonna choose column A.

dim LastRow as long
with activesheet
lastrow = .cells(.rows.count,"A").end(xlup).row
with .range("a10:V" & lastrow
.sort key1:=.columns(1), order1:=xlascending, _
header:=xlno, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
end with
end with

ScottPcola wrote:

My worksheet consists of some fairly straight forward columns and I have
built macros with assigned Command Buttons to sort by their relative column.

This worksheet is a master worksheet of which copies are distributed to
several sales reps that will have varying numbers of rows that they will
populate but no more than 200 rows.

My intent is to modify my Macros so that they do not include blank rows in
the sorting - (i.e. if a sales reps' sheet only contains 175 rows, I always
want the blank rows (176-200) to remain at the bottom.

Here is an example of one of my sorting macros for one of the columns:

Sub Sort_Rank()
Range("A10:V210").Select
Selection.Sort Key1:=Range("A10"), Order1:=xlAscending, Header:=xlNo, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal
End Sub

I should point out that the range only includes the rows and columns of data
- it does not include column headers

Thanks for your help in advance,

Scott


--

Dave Peterson
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 delete rows with same data Connie Martin Excel Worksheet Functions 12 November 22nd 05 01:18 PM
How can I sort in groups of 3 rows? Blue Excel Worksheet Functions 1 November 15th 05 10:11 PM
macro to hide rows if cell is blank Shooter Excel Worksheet Functions 3 September 28th 05 10:55 PM
Pivot Tables & not printing blank rows (revisited) [email protected] Excel Worksheet Functions 1 August 4th 05 07:42 AM
Activate a macro to insert a row and copy the formuals from the rows above to the blank row oil_driller Excel Discussion (Misc queries) 1 February 11th 05 03:30 PM


All times are GMT +1. The time now is 01:14 PM.

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

About Us

"It's about Microsoft Excel"