LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default sort a column

Following up on Dave's suggestion to "drop the select and activates from
your code", perhaps this previous posting of mine (a response to another
person using Select/Selection type constructions) will be of some help to
you in your future programming (note, you can replace the Select property
with the Activate property in the examples below and everything will still
apply)...

Whenever you see code constructed like this...

Range("A1").Select
Selection.<whatever

you can almost always do this instead...

Range("A1").<whatever

In your particular case, you have this...

Range("C2:C8193").Select 'select cells to export
For Each r In Selection.Rows

which, using the above concept, can be reduced to this...

For Each r In Range("C2:C8193").Rows

Notice, all I have done is replace Selection with the range you Select(ed)
in the previous statement and eliminate the process of doing any
Select(ion)s. Stated another way, the Selection produced from
Range(...).Select is a range and, of course, Range(...) is a range... and,
in fact, they are the same range, so it doesn't matter which one you use.
The added benefit of not selecting ranges first is your active cell does not
change.


--
Rick (MVP - Excel)


"Withnails" wrote in message
...
hello
i am looking to sort a data table by column I. the amount of rows in
column
I will change over time. when i record this macro it send up an error
(application or object is not defined).
this all happens on sheet two of the worksheet in question.
Can you help and let me know why this error is happening, i'm at a loss?!
thank you - philip

PS: code i have been using is...
Sheets("Sheet2").Select
Cells.Select
Range("A1").Activate
Selection.Sort Key1:=Range("I2"), Order1:=xlDescending,
Header:=xlGuess, _
OrderCustom:=1, MatchCase:=False, Orientation:=xlTopToBottom, _
DataOption1:=xlSortNormal


 
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
How to sort entire spreadsheet by one column sort jbclem Excel Discussion (Misc queries) 6 April 2nd 23 08:06 PM
How to sort without including column headings in sort OPDvolunteer Excel Discussion (Misc queries) 4 March 11th 09 04:08 PM
Auto-Sort Won't Sort All Column Cells TikiTembo Excel Discussion (Misc queries) 1 March 25th 08 07:00 PM
data, sort option is grayed. how to sort on a column? Steve Richter Excel Discussion (Misc queries) 1 September 25th 07 03:25 PM
How can I sort one column and have the entire row sort. (binding) Blue Excel Worksheet Functions 10 November 13th 05 07:09 PM


All times are GMT +1. The time now is 12:15 AM.

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"