sorting a table, how to auto grab the whole table

sfarnsworth

New Member
Joined
Aug 25, 2002
Messages
3
Hi, I feel silly asking such a question. I've done some looking for the answer but haven't found it. If it's in another post, thanks to just point me in that direction...

Here's my Q...

If I have my cursor on any cell in a table and I click on "Sort" (from the pulldown) in Excel 2000, Excel selects the whole table automatically. If the table is 5 columns wide and 10 rows long, it grabs and sorts 50 cells (assuming I don't have any rows or columns in my table completely empty -- I'm OK to live with that).

If I now add two more rows of data and do exactly the same thing that I did before (Sort from the pulldown with one cell in my table selected), now, instead of sorting 50 cells, the system intelligently notices the two additional rows and now sorts the whole 60 cells. I didn't have to do anything differently.

Now, I create a macro to do this same sorting. Only now, when I add two more rows, the macro doesn't "keep up". It doesn't notice that the table now has two more rows. It has, in recording the macro, recorded exactly the size of the table at that point.

Is there any easy way to say "just go ahead and do the whole table" in the macro world like there is in the real world?

Thanks in advance.
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Replace the line in the macro that selects the range with

Selection.CurrentRegion.Select

HTH
 
Upvote 0

Forum statistics

Threads
1,214,805
Messages
6,121,665
Members
449,045
Latest member
Marcus05

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top