Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 143
Default Auto-sort data tables after refresh

I have an Excel 2007 workbook that has a number of data tables fed from
Access. The tables contain financial data in a crosstab with the customer
name as the row, the month end date as the column and the sum of the monthly
amounts as the value.

The last column of each table is a sum for YTD 2009. Currently, I go
through each worksheet, update the formula to include the most current month
and sort the total decending. The sort is critical to properly rank the
customers for each worksheet. (I have tried the ranking function, but some
customers will have zero or negative purchases for the year, so I end up with
ties. I have tried many different tie-breaking methods, but all of them have
failed at one point or another).

Here is what I have so far:
Sub SortTables()
Dim ws As Worksheet

Application.Calculation = xlCalculationManual
Application.ScreenUpdating = False

For Each ws In Worksheets

ws.ListObjects("Table_Trinity.accdb6912" _
).Sort.SortFields.Clear
ws.ListObjects("Table_Trinity.accdb6912" _
).Sort.SortFields.Add Key:=Range( _
"Table_Trinity.accdb6912[[#Headers],[SortColumn]]"),
SortOn:=xlSortOnValues, _
Order:=xlDescending, DataOption:=xlSortTextAsNumbers
With ws.ListObjects( _
"Table_Trinity.accdb6912").Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With

Next ws

Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True

End Sub

This works great for the first sheet that has table 6912 on it, but what I
don't know how to do is to replace the "Table_Trinity.accdb6912" with 'the
table on the current worksheet'.

Is there a way to do that?

Thanks!

PJ
Reply
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
Pivot tables and replacing data, then refresh it Michael B[_2_] Excel Discussion (Misc queries) 1 January 8th 09 06:40 PM
Auto Refresh of Pivot Tables not working meo Excel Worksheet Functions 0 March 13th 08 05:31 PM
Pivot Tables - Missing Data after refresh Gr8Day Excel Worksheet Functions 0 July 7th 06 02:55 PM
How can I auto-refresh auto-filters when data changes? Mike@MPWco Excel Worksheet Functions 0 July 4th 06 12:50 PM
Pivot Tables -- Auto Refresh Aastha Excel Discussion (Misc queries) 1 March 30th 06 08:12 PM


All times are GMT +1. The time now is 02:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"