Home |
Search |
Today's Posts |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How to sort entire spreadsheet by one column sort | Excel Discussion (Misc queries) | |||
How to sort without including column headings in sort | Excel Discussion (Misc queries) | |||
Auto-Sort Won't Sort All Column Cells | Excel Discussion (Misc queries) | |||
data, sort option is grayed. how to sort on a column? | Excel Discussion (Misc queries) | |||
How can I sort one column and have the entire row sort. (binding) | Excel Worksheet Functions |