PC Review


Reply
Thread Tools Rate Thread

how to define a range

 
 
nk
Guest
Posts: n/a
 
      19th Jul 2007
I'm trying to create a small VBA program for sorting a range by 3
paramters by using the Recording Macro tool. the table to sort is
varying by the rows between times of sorting

Before begining the recording I choose the active cell to be on
the table header row and then entered the following sequensce:
<end> <left arrow> <shift><end><down arrow> (while continue holding
the <shift>) <left aroow> 13 times - to reach the right botom of the
table (some of the culomns are not filled) and then I did the sorting.

following is what was actually recorded:

Selection.End(xlToLeft).Select
Range(Selection, Selection.End(xlDown)).Select
ActiveCell.Range("A1:N1511").Select
Selection.Sort Key1:=ActiveCell.Offset(0, 11).Range("A1"),
Order1:= _
xlAscending, Key2:=ActiveCell.Offset(0, 13).Range("A1"),
Order2:=xlAscending _
, Key3:=ActiveCell.Offset(0, 8).Range("A1"),
Order3:=xlAscending, Header:= _
xlGuess, OrderCustom:=1, MatchCase:=False,
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, DataOption2:=xlSortNormal,
DataOption3:= _
xlSortNormal
End Sub

in the 3rd row the range was transormed to fix range (?)

how to fix it?

Regards, nk

 
Reply With Quote
 
 
 
 
=?Utf-8?B?VmVyZ2VsIEFkcmlhbm8=?=
Guest
Posts: n/a
 
      19th Jul 2007
nk,

try this:

ActiveSheet.UsedRange.Select
Selection.Sort Key1:=ActiveCell.Offset(0, 11).Range("A1"), _
Order1:=xlAscending, _
Key2:=ActiveCell.Offset(0, 13).Range("A1"), _
Order2:=xlAscending, _
Key3:=ActiveCell.Offset(0, 8).Range("A1"), _
Order3:=xlAscending, _
Header:=xlGuess, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal, _
DataOption2:=xlSortNormal, _
DataOption3:=xlSortNormal


--
Hope that helps.

Vergel Adriano


"nk" wrote:

> I'm trying to create a small VBA program for sorting a range by 3
> paramters by using the Recording Macro tool. the table to sort is
> varying by the rows between times of sorting
>
> Before begining the recording I choose the active cell to be on
> the table header row and then entered the following sequensce:
> <end> <left arrow> <shift><end><down arrow> (while continue holding
> the <shift>) <left aroow> 13 times - to reach the right botom of the
> table (some of the culomns are not filled) and then I did the sorting.
>
> following is what was actually recorded:
>
> Selection.End(xlToLeft).Select
> Range(Selection, Selection.End(xlDown)).Select
> ActiveCell.Range("A1:N1511").Select
> Selection.Sort Key1:=ActiveCell.Offset(0, 11).Range("A1"),
> Order1:= _
> xlAscending, Key2:=ActiveCell.Offset(0, 13).Range("A1"),
> Order2:=xlAscending _
> , Key3:=ActiveCell.Offset(0, 8).Range("A1"),
> Order3:=xlAscending, Header:= _
> xlGuess, OrderCustom:=1, MatchCase:=False,
> Orientation:=xlTopToBottom, _
> DataOption1:=xlSortNormal, DataOption2:=xlSortNormal,
> DataOption3:= _
> xlSortNormal
> End Sub
>
> in the 3rd row the range was transormed to fix range (?)
>
> how to fix it?
>
> Regards, nk
>
>

 
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
define a range that equals the first row of another range Richard Microsoft Excel Programming 5 1st Dec 2010 05:53 AM
Define a Range based on a Range object Terry Microsoft Excel Programming 4 25th Oct 2010 08:44 PM
Define a range jlclyde Microsoft Excel Misc 2 17th Apr 2008 08:26 PM
Define a range based on another named range =?Utf-8?B?QmFzaWw=?= Microsoft Excel Worksheet Functions 2 21st Feb 2005 01:47 PM
To Define Name Instead of Range Mathew P Bennett Microsoft Excel Misc 2 29th Nov 2003 04:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:00 PM.