close

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(quot;A10:V210quot;).Select
Selection.Sort Key1:=Range(quot;A10quot;), 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,

ScottCan 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,quot;Aquot;).end(xlup).row
with .range(quot;a10:Vquot; amp; lastrow
.sort key1:=.columns(1), order1:=xlascending, _
header:=xlno, OrderCustom:=1, MatchCase:=False, _
Orientation:=xlTopToBottom, DataOption1:=xlSortNormal
end with
end with

ScottPcola wrote:
gt;
gt; My worksheet consists of some fairly straight forward columns and I have
gt; built macros with assigned Command Buttons to sort by their relative column.
gt;
gt; This worksheet is a master worksheet of which copies are distributed to
gt; several sales reps that will have varying numbers of rows that they will
gt; populate but no more than 200 rows.
gt;
gt; My intent is to modify my Macros so that they do not include blank rows in
gt; the sorting - (i.e. if a sales reps' sheet only contains 175 rows, I always
gt; want the blank rows (176-200) to remain at the bottom.
gt;
gt; Here is an example of one of my sorting macros for one of the columns:
gt;
gt; Sub Sort_Rank()
gt; Range(quot;A10:V210quot;).Select
gt; Selection.Sort Key1:=Range(quot;A10quot;), Order1:=xlAscending, Header:=xlNo, _
gt; OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
gt; DataOption1:=xlSortNormal
gt; End Sub
gt;
gt; I should point out that the range only includes the rows and columns of data
gt; - it does not include column headers
gt;
gt; Thanks for your help in advance,
gt;
gt; Scott

--

Dave Peterson

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 software 的頭像
    software

    software

    software 發表在 痞客邦 留言(0) 人氣()