Sorting information in a number of sheets by the same Column Header

fluffynicesheep

Board Regular
Joined
Oct 27, 2009
Messages
69
Hi,

I have previously been inserting RSS feeds (as an HTML table) into an excel document and running the below code to update the details and sort by the date column in all tables, when the document opened. When finished the document then saved and closed.

All was working great until I needed to enter some more RSS details, and now there seems to be an issue with doing this ....

I now can only insert data from web as RTF and not HTML, so it no longer goes into a formatted table. I have however added a column to the end of the newly imported data that adds DATEVALUE. I have called this column header DATEVALUE and added filters to the header row.

What I would like to do is add some additional code to the code below that will look through all worksheets, and if it finds a column header that contains the name "DATEVALUE" that it then sorts the rows in descending order. (This could come before or after the current table sort in the code).


Any help would be greatly appreciated.



Code:
Private Sub Workbook_Activate()
ActiveWorkbook.RefreshAll
DoEvents
Application.DisplayAlerts = False
 
      Dim ws As Worksheet, t As ListObject
    On Error Resume Next
    For Each ws In Sheets
        For Each t In ws.ListObjects
            t.Range.Sort key1:=t.Name & "[DATE]", Order1:=xlDescending
        Next
    Next
   
    ThisWorkbook.Save
Application.DisplayAlerts = True
Application.Quit

End Sub
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi,

Just wondering if anyone has any ideas on the code that I can add in order to loop through all worksheets and if it finds a column header (in row 3) that contains the name "DATEVALUE" that it then sorts the data by that date in descending order. (This could come before or after the current table sort in the code). Thanks all
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,322
Members
452,635
Latest member
laura12345

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